[Libreoffice-commits] online.git: net/Ssl.cpp

Christian Glombek christian.glombek at rwth-aachen.de
Wed Sep 20 01:48:26 UTC 2017


 net/Ssl.cpp |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 702bbdd5d8dd31eda8a2dfdb726be3c6cd978ec2
Author: Christian Glombek <christian.glombek at rwth-aachen.de>
Date:   Sat Sep 16 08:38:01 2017 +0200

    Add Support for OpenSSL 1.1.0
    
    Change-Id: I0aa58b893e8577bba94fa45c0c4c81449b12e4e2
    Reviewed-on: https://gerrit.libreoffice.org/42356
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/net/Ssl.cpp b/net/Ssl.cpp
index 7c04cbd9..5a9f8280 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");


More information about the Libreoffice-commits mailing list