diff options
-rw-r--r-- | net/Ssl.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/net/Ssl.cpp b/net/Ssl.cpp index 7c04cbd95..5a9f8280b 100644 --- a/net/Ssl.cpp +++ b/net/Ssl.cpp @@ -42,13 +42,18 @@ SslContext::SslContext(const std::string& certFilePath, _mutexes.emplace_back(new std::mutex); } -#if OPENSSL_VERSION_NUMBER >= 0x0907000L +#if OPENSSL_VERSION_NUMBER >= 0x0907000L && OPENSSL_VERSION_NUMBER < 0x10100003L OPENSSL_config(nullptr); #endif +#if OPENSSL_VERSION_NUMBER >= 0x10100003L + SSL_CTX_set_options(nullptr, 0); + OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL); +#else SSL_library_init(); SSL_load_error_strings(); OpenSSL_add_all_algorithms(); +#endif CRYPTO_set_locking_callback(&SslContext::lock); CRYPTO_set_id_callback(&SslContext::id); @@ -234,10 +239,19 @@ void SslContext::initDH() throw std::runtime_error("Error creating Diffie-Hellman parameters: " + msg); } +#if OPENSSL_VERSION_NUMBER >= 0x10100003L + // OpenSSL v1.1.0 has public API changes + // p, g and length of the Diffie-Hellman param can't be set directly anymore, + // instead DH_set0_pqg and DH_set_length are used + BIGNUM* p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0); + BIGNUM* g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0); + if ((DH_set0_pqg(dh, p, NULL, g) == 0) || (DH_set_length(dh, 160) == 0)) +#else dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0); dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0); dh->length = 160; if ((!dh->p) || (!dh->g)) +#endif { DH_free(dh); throw std::runtime_error("Error creating Diffie-Hellman parameters"); |