diff --git a/src/Tls.cpp b/src/Tls.cpp index 1700f6d2..e98a092b 100644 --- a/src/Tls.cpp +++ b/src/Tls.cpp @@ -279,9 +279,13 @@ bool TlsSession_openssl::verifyHostname(X509* certificate, const char* hostname) int count = sk_GENERAL_NAME_num(names); for (int i = 0; i < count; ++i) { const GENERAL_NAME* check = sk_GENERAL_NAME_value(names, i); +#if OPENSSL_VERSION_NUMBER <= 0x1000211fL + const unsigned char* name = ASN1_STRING_data(check->d.ia5); +#else const char* name = ASN1_STRING_get0_data(check->d.ia5); +#endif size_t length = ASN1_STRING_length(check->d.ia5); - if (wildcardMatch(std::string(name, length).c_str(), hostname)) { + if (wildcardMatch(std::string((const char*)name, length).c_str(), hostname)) { verified = true; break; } @@ -295,9 +299,13 @@ bool TlsSession_openssl::verifyHostname(X509* certificate, const char* hostname) if (entry) { ASN1_STRING* asn1 = X509_NAME_ENTRY_get_data(entry); if (asn1) { +#if OPENSSL_VERSION_NUMBER <= 0x1000211fL + const unsigned char* commonName = ASN1_STRING_data(asn1); +#else const char* commonName = ASN1_STRING_get0_data(asn1); - if (static_cast(ASN1_STRING_length(asn1)) == std::strlen(commonName)) { - verified = wildcardMatch(commonName, hostname); +#endif + if (static_cast(ASN1_STRING_length(asn1)) == std::strlen((const char*)commonName)) { + verified = wildcardMatch((const char*)commonName, hostname); } } }