Describe the bug
Poco fails to build against OpenSSL 3.6.3 that was built with no-deprecated=true
To Reproduce
Will investigate small sample project to demonstrate build missing.
openssl/3.6.3
poco/1.15.2
Conan config
[options]
openssl/:shared=False
openssl/:no_deprecated=True
openssl/:no_legacy=True
poco/:shared=False
Expected behavior
expand current identification in usage of OpenSSL items marked deprecated so that no-deprecated may be used.
Logs
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp: In static member function ‘static int Poco::Net::SSLManager::verifyOCSPResponseCallback(SSL*, void*)’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp:305:20: error: ‘SSL_get_peer_certificate’ was not declared in this scope
X509* pPeerCert = SSL_get_peer_certificate(pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp:305:20: note: suggested alternative: ‘SSL_get1_peer_certificate’
X509* pPeerCert = SSL_get_peer_certificate(pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/build.make:327: recipe for target 'NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/src/SSLManager.cpp.o' failed
gmake[2]: *** [NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/src/SSLManager.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp: In member function ‘long int Poco::Net::SecureSocketImpl::verifyPeerCertificateImpl(const string&)’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:490:20: error: ‘::SSL_get_peer_certificate’ has not been declared
::X509* pCert = ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:490:20: note: suggested alternative: ‘SSL_get1_peer_certificate’
::X509* pCert = ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp: In member function ‘X509* Poco::Net::SecureSocketImpl::peerCertificate() const’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:519:12: error: ‘::SSL_get_peer_certificate’ has not been declared
return ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:519:12: note: suggested alternative: ‘SSL_get1_peer_certificate’
return ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
Please add relevant environment information:
- OS Type and Version: Linux, SUSE 12 SP5
- POCO Version: 1.15.2
- Built from conan2 recipe, gcc8
|
X509* pPeerCert = SSL_get_peer_certificate(pSSL); |
|
#if defined(_MSC_VER) |
|
#pragma warning(disable:4996) // deprecation warnings |
|
#endif |
|
::X509* pCert = ::SSL_get_peer_certificate(_pSSL); |
|
return ::SSL_get_peer_certificate(_pSSL); |
Additional context
AI Overview
In OpenSSL 3.0, SSL_get_peer_certificate has been deprecated. It is replaced by SSL_get1_peer_certificate or SSL_get0_peer_certificate, which handle certificate reference counting explicitly.If you are upgrading an older codebase to OpenSSL 3, you will likely see compilation warnings or linker errors like undefined reference to SSL_get_peer_certificate if your environment compiles with OPENSSL_NO_DEPRECATED enabled.
Recommended Replacements
You should modify your code to use one of the two new functions depending on how you manage memory:
SSL_get1_peer_certificate() 1
Behavior: Identical to the deprecated function.
Memory Management: It increments the reference count of the X509 object.
Action Required: You must explicitly free the pointer using X509_free() when you are done with it to avoid memory leaks.
SSL_get0_peer_certificate()
Behavior: Returns a pointer to the internal certificate object.
Memory Management: It does not increment the reference count.
Action Required: Do not free this pointer. The memory is tied to the lifecycle of the SSL connection object.
Describe the bug
Poco fails to build against OpenSSL 3.6.3 that was built with no-deprecated=true
To Reproduce
Will investigate small sample project to demonstrate build missing.
openssl/3.6.3
poco/1.15.2
Conan config
[options]
openssl/:shared=False
openssl/:no_deprecated=True
openssl/:no_legacy=True
poco/:shared=False
Expected behavior
expand current identification in usage of OpenSSL items marked deprecated so that no-deprecated may be used.
Logs
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp: In static member function ‘static int Poco::Net::SSLManager::verifyOCSPResponseCallback(SSL*, void*)’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp:305:20: error: ‘SSL_get_peer_certificate’ was not declared in this scope
X509* pPeerCert = SSL_get_peer_certificate(pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SSLManager.cpp:305:20: note: suggested alternative: ‘SSL_get1_peer_certificate’
X509* pPeerCert = SSL_get_peer_certificate(pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/build.make:327: recipe for target 'NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/src/SSLManager.cpp.o' failed
gmake[2]: *** [NetSSL_OpenSSL/CMakeFiles/NetSSL.dir/src/SSLManager.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp: In member function ‘long int Poco::Net::SecureSocketImpl::verifyPeerCertificateImpl(const string&)’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:490:20: error: ‘::SSL_get_peer_certificate’ has not been declared
::X509* pCert = ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:490:20: note: suggested alternative: ‘SSL_get1_peer_certificate’
::X509* pCert = ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp: In member function ‘X509* Poco::Net::SecureSocketImpl::peerCertificate() const’:
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:519:12: error: ‘::SSL_get_peer_certificate’ has not been declared
return ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
/builds/.conan2/p/b/poco6758757fc253f/b/src/NetSSL_OpenSSL/src/SecureSocketImpl.cpp:519:12: note: suggested alternative: ‘SSL_get1_peer_certificate’
return ::SSL_get_peer_certificate(_pSSL);
^~~~~~~~~~~~~~~~~~~~~~~~
SSL_get1_peer_certificate
Please add relevant environment information:
poco/NetSSL_OpenSSL/src/SSLManager.cpp
Line 304 in 1dd2780
poco/NetSSL_OpenSSL/src/SSLManager.cpp
Lines 15 to 17 in 1dd2780
poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp
Line 489 in 1dd2780
poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp
Line 518 in 1dd2780
Additional context
AI Overview
In OpenSSL 3.0, SSL_get_peer_certificate has been deprecated. It is replaced by SSL_get1_peer_certificate or SSL_get0_peer_certificate, which handle certificate reference counting explicitly.If you are upgrading an older codebase to OpenSSL 3, you will likely see compilation warnings or linker errors like undefined reference to SSL_get_peer_certificate if your environment compiles with OPENSSL_NO_DEPRECATED enabled.
Recommended Replacements
You should modify your code to use one of the two new functions depending on how you manage memory:
SSL_get1_peer_certificate() 1
Behavior: Identical to the deprecated function.
Memory Management: It increments the reference count of the X509 object.
Action Required: You must explicitly free the pointer using X509_free() when you are done with it to avoid memory leaks.
SSL_get0_peer_certificate()
Behavior: Returns a pointer to the internal certificate object.
Memory Management: It does not increment the reference count.
Action Required: Do not free this pointer. The memory is tied to the lifecycle of the SSL connection object.