Skip to content

Commit

Permalink
IsCertUptodate(): allow raw pointer input
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Nov 6, 2023
1 parent b3315a4 commit 415ea3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/base/tlsutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ std::shared_ptr<X509> CreateCertIcingaCA(const std::shared_ptr<X509>& cert)
return CreateCertIcingaCA(pkey.get(), X509_get_subject_name(cert.get()));
}

bool IsCertUptodate(const std::shared_ptr<X509>& cert)
bool IsCertUptodate(X509* cert)
{
time_t now;
time(&now);
Expand All @@ -771,7 +771,7 @@ bool IsCertUptodate(const std::shared_ptr<X509>& cert)
time_t forceRenewalEnd = 1483228800; /* January 1st, 2017 */
time_t renewalStart = now + RENEW_THRESHOLD;

return X509_cmp_time(X509_get_notBefore(cert.get()), &forceRenewalEnd) != -1 && X509_cmp_time(X509_get_notAfter(cert.get()), &renewalStart) != -1;
return X509_cmp_time(X509_get_notBefore(cert), &forceRenewalEnd) != -1 && X509_cmp_time(X509_get_notAfter(cert), &renewalStart) != -1;
}

String CertificateToString(const std::shared_ptr<X509>& cert)
Expand Down
7 changes: 6 additions & 1 deletion lib/base/tlsutility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ String CertificateToString(const std::shared_ptr<X509>& cert);
std::shared_ptr<X509> StringToCertificate(const String& cert);
std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject, bool ca = false);
std::shared_ptr<X509> CreateCertIcingaCA(const std::shared_ptr<X509>& cert);
bool IsCertUptodate(const std::shared_ptr<X509>& cert);
bool IsCertUptodate(X509* cert);

inline bool IsCertUptodate(const std::shared_ptr<X509>& cert)
{
return IsCertUptodate(cert.get());
}

String PBKDF2_SHA1(const String& password, const String& salt, int iterations);
String PBKDF2_SHA256(const String& password, const String& salt, int iterations);
Expand Down

0 comments on commit 415ea3a

Please sign in to comment.