From c7b13dd1ae2396bddad332befd0f4df4b74a8242 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 29 Sep 2019 21:05:49 +0000 Subject: [PATCH] Build for whichever openssl. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3422 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/Tls.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); } } }