Skip to content

Commit f83ec7f

Browse files
Reach full compatibility with OpenSSL 1.1
Despite what the documentation[1] says the code is not fully compatible with OpenSSL 1.1 because it relies on compatibility wrappers behind OPENSSL_API_COMPAT. The OpenSSL documentation on library initialization[2] explains that none of the startup fucntions are necessary starting with 1.1. The changelog for "changes between 1.0.2h and 1.1.0 [25 Aug 2016]"[3] mentions several removed shutdown functions. The removal of `CRYPTO_set_locking_callback` is mentioned in a GitHub comment[4]. [1] https://docs.datastax.com/en/developer/cpp-driver/2.15/topics/building/ [2] https://wiki.openssl.org/index.php/Library_Initialization [3] https://www.openssl.org/news/changelog.html [4] openssl/openssl#1260 (comment)
1 parent 2b3fb19 commit f83ec7f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ssl/ssl_openssl_impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,11 @@ void free(void* ptr, const char* file, int line) { Memory::free(ptr); }
620620
void OpenSslContextFactory::internal_init() {
621621
CRYPTO_set_mem_functions(openssl::malloc, openssl::realloc, openssl::free);
622622

623+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
623624
SSL_library_init();
624625
SSL_load_error_strings();
625626
OpenSSL_add_all_algorithms();
627+
#endif
626628

627629
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
628630
// We have to set the lock/id callbacks for use of OpenSSL thread safety.
@@ -654,15 +656,19 @@ void OpenSslContextFactory::internal_thread_cleanup() {
654656
}
655657

656658
void OpenSslContextFactory::internal_cleanup() {
659+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
657660
RAND_cleanup();
658661
ENGINE_cleanup();
662+
#endif
659663
CONF_modules_unload(1);
664+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
660665
CONF_modules_free();
661666
EVP_cleanup();
662667
ERR_free_strings();
663668
CRYPTO_cleanup_all_ex_data();
664669
CRYPTO_set_locking_callback(NULL);
665670
CRYPTO_set_id_callback(NULL);
671+
#endif
666672
#if OPENSSL_VERSION_NUMBER < 0x10100000L && OPENSSL_VERSION_NUMBER > 0x10002000L
667673
SSL_COMP_free_compression_methods();
668674
#endif

0 commit comments

Comments
 (0)