From c11d1eebb031daaa8e1e1b963e4897c84ce56596 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 2 Nov 2019 22:31:21 -0700 Subject: [PATCH] X509Certificate: Get rid of deprecated OpenSSL 1.1 APIs Added a missing implicit header and added compatibility macros. Signed-off-by: Rosen Penev --- Crypto/src/X509Certificate.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Crypto/src/X509Certificate.cpp b/Crypto/src/X509Certificate.cpp index bea1e459e..6dddb2149 100644 --- a/Crypto/src/X509Certificate.cpp +++ b/Crypto/src/X509Certificate.cpp @@ -27,7 +27,13 @@ #include #include #include +#include +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#define ASN1_STRING_get0_data ASN1_STRING_data +#define X509_get0_notBefore X509_get_notBefore +#define X509_get0_notAfter X509_get_notAfter +#endif namespace Poco { namespace Crypto { @@ -255,7 +261,7 @@ void X509Certificate::extractNames(std::string& cmnName, std::set& const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i); if (name->type == GEN_DNS) { - const char* data = reinterpret_cast(ASN1_STRING_data(name->d.ia5)); + const char* data = reinterpret_cast(ASN1_STRING_get0_data(name->d.ia5)); std::size_t len = ASN1_STRING_length(name->d.ia5); domainNames.insert(std::string(data, len)); } @@ -273,7 +279,7 @@ void X509Certificate::extractNames(std::string& cmnName, std::set& Poco::DateTime X509Certificate::validFrom() const { - ASN1_TIME* certTime = X509_get_notBefore(_pCert); + const ASN1_TIME* certTime = X509_get0_notBefore(_pCert); std::string dateTime(reinterpret_cast(certTime->data)); int tzd; return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd); @@ -282,7 +288,7 @@ Poco::DateTime X509Certificate::validFrom() const Poco::DateTime X509Certificate::expiresOn() const { - ASN1_TIME* certTime = X509_get_notAfter(_pCert); + const ASN1_TIME* certTime = X509_get0_notAfter(_pCert); std::string dateTime(reinterpret_cast(certTime->data)); int tzd; return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);