From 5551fec2ff6db6fd87542bcffb7c968f21a739bb Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 20 Oct 2026 22:34:02 +0200 Subject: fix(openssl): support const-correct certificate APIs - handle const X509 subject names with OpenSSL 3 - use ASN1_STRING_get0_data on OpenSSL 1.1 and newer - retain compatibility with older OpenSSL releases --- src/vmime/security/cert/openssl/X509Certificate_OpenSSL.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vmime/security/cert/openssl/X509Certificate_OpenSSL.cpp b/src/vmime/security/cert/openssl/X509Certificate_OpenSSL.cpp index 5df8703c..c949ab03 100644 --- a/src/vmime/security/cert/openssl/X509Certificate_OpenSSL.cpp +++ b/src/vmime/security/cert/openssl/X509Certificate_OpenSSL.cpp @@ -437,7 +437,11 @@ bool X509Certificate_OpenSSL::verifyHostName( char CNBuffer[1024]; CNBuffer[sizeof(CNBuffer) - 1] = '\0'; +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + const X509_NAME* xname = X509_get_subject_name(m_data->cert); +#else X509_NAME* xname = X509_get_subject_name(m_data->cert); +#endif if (X509_NAME_get_text_by_NID(xname, NID_commonName, CNBuffer, sizeof(CNBuffer)) != -1) { @@ -468,7 +472,11 @@ bool X509Certificate_OpenSSL::verifyHostName( if (currentName->type == GEN_DNS) { // Current name is a DNS name, let's check it - char *DNSName = (char *) ASN1_STRING_data(currentName->d.dNSName); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const char *DNSName = (const char *) ASN1_STRING_get0_data(currentName->d.dNSName); +#else + const char *DNSName = (const char *) ASN1_STRING_data(currentName->d.dNSName); +#endif // Make sure there isn't an embedded NUL character in the DNS name if (ASN1_STRING_length(currentName->d.dNSName) != strlen(DNSName)) { -- cgit