IsCertUptodate(): allow raw pointer input

This commit is contained in:
Alexander A. Klimov 2023-11-06 13:59:15 +01:00
parent b3315a4f7e
commit 415ea3a5b7
2 changed files with 8 additions and 3 deletions

View File

@ -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);
@ -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)

View File

@ -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);