diff --git a/NetSSL_OpenSSL/src/X509Certificate.cpp b/NetSSL_OpenSSL/src/X509Certificate.cpp index e1e773f7e..54651c3ac 100644 --- a/NetSSL_OpenSSL/src/X509Certificate.cpp +++ b/NetSSL_OpenSSL/src/X509Certificate.cpp @@ -82,6 +82,7 @@ bool X509Certificate::verify(const std::string& hostName) const bool X509Certificate::verify(const Poco::Crypto::X509Certificate& certificate, const std::string& hostName) { +#if OPENSSL_VERSION_NUMBER < 0x10002000L std::string commonName; std::set dnsNames; certificate.extractNames(commonName, dnsNames); @@ -131,6 +132,21 @@ bool X509Certificate::verify(const Poco::Crypto::X509Certificate& certificate, c } } return ok; +#else + if (X509_check_host(const_cast(certificate.certificate()), hostName.c_str(), hostName.length(), 0, NULL) == 1) + { + return true; + } + else + { + IPAddress ip; + if (IPAddress::tryParse(hostName, ip)) + { + return (X509_check_ip_asc(const_cast(certificate.certificate()), hostName.c_str(), 0) == 1); + } + } + return false; +#endif }