Procházet zdrojové kódy

Support OpenSSL 1.1.

Some help from https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes
Bryan Drewery před 8 roky
rodič
revize
d30804041f
3 změnil soubory, kde provedl 23 přidání a 8 odebrání
  1. 4 4
      src/libcrypto.cc
  2. 17 4
      src/libssl.cc
  3. 2 0
      src/openssl.cc

+ 4 - 4
src/libcrypto.cc

@@ -49,7 +49,6 @@ static int load_symbols(void *handle) {
   DLSYM_GLOBAL(handle, BF_encrypt);
   DLSYM_GLOBAL(handle, BF_set_key);
   DLSYM_GLOBAL(handle, ERR_error_string);
-  DLSYM_GLOBAL(handle, ERR_free_strings);
   DLSYM_GLOBAL(handle, ERR_get_error);
   DLSYM_GLOBAL(handle, OPENSSL_cleanse);
   DLSYM_GLOBAL(handle, RAND_file_name);
@@ -87,10 +86,11 @@ static int load_symbols(void *handle) {
   DLSYM_GLOBAL(handle, DH_set0_key);
   DLSYM_GLOBAL(handle, DH_set0_pqg);
   DLSYM_GLOBAL(handle, BN_free);
-#endif
+#else
+  DLSYM_GLOBAL(handle, ERR_free_strings);
   DLSYM_GLOBAL(handle, EVP_cleanup);
   DLSYM_GLOBAL(handle, CRYPTO_cleanup_all_ex_data);
-
+#endif
 
   return 0;
 }
@@ -103,7 +103,7 @@ int load_libcrypto() {
 
   sdprintf("Loading libcrypto");
 
-  bd::Array<bd::String> libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.1.0.0 libcrypto.so.0.9.8 libcrypto.so.8 libcrypto.so.7 libcrypto.so.6").split(' '));
+  bd::Array<bd::String> libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.1.0.1 libcrypto.so.1.0.0 libcrypto.so.0.9.8 libcrypto.so.10 libcrypto.so.9 libcrypto.so.8 libcrypto.so.7 libcrypto.so.6").split(' '));
 
   for (size_t i = 0; i < libs_list.length(); ++i) {
     dlerror(); // Clear Errors

+ 17 - 4
src/libssl.cc

@@ -45,18 +45,31 @@ static int load_symbols(void *handle) {
   DLSYM_GLOBAL(handle, SSL_CTX_free);
   DLSYM_GLOBAL(handle, SSL_CTX_new);
   DLSYM_GLOBAL(handle, SSL_free);
-  DLSYM_GLOBAL(handle, SSL_library_init);
-  DLSYM_GLOBAL(handle, SSL_load_error_strings);
   DLSYM_GLOBAL(handle, SSL_new);
   DLSYM_GLOBAL(handle, SSL_pending);
   DLSYM_GLOBAL(handle, SSL_read);
   DLSYM_GLOBAL(handle, SSL_set_fd);
   DLSYM_GLOBAL(handle, SSL_shutdown);
-  DLSYM_GLOBAL(handle, SSLv23_client_method);
   DLSYM_GLOBAL(handle, SSL_write);
   DLSYM_GLOBAL(handle, SSL_CTX_ctrl);
   DLSYM_GLOBAL(handle, SSL_CTX_set_cipher_list);
   DLSYM_GLOBAL(handle, SSL_CTX_set_tmp_dh_callback);
+#if defined(OPENSSL_API_COMPAT) && OPENSSL_API_COMPAT < 0x10100000L
+  /* For SSL_library_init and SSL_load_error_strings. */
+  DLSYM_GLOBAL(handle, OPENSSL_init_ssl);
+#else
+  DLSYM_GLOBAL(handle, SSL_library_init);
+  DLSYM_GLOBAL(handle, SSL_load_error_strings);
+#endif
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+  /* For SSLv23_client_method */
+  DLSYM_GLOBAL(handle, TLS_client_method);
+  /* For SSLv23_method */
+  DLSYM_GLOBAL(handle, TLS_method);
+  DLSYM_GLOBAL(handle, SSL_CTX_set_options);
+#else
+  DLSYM_GLOBAL(handle, SSLv23_client_method);
+#endif
 
   return 0;
 }
@@ -69,7 +82,7 @@ int load_libssl() {
 
   sdprintf("Loading libssl");
 
-  bd::Array<bd::String> libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.1.0.0 libssl.so.0.9.8 libssl.so.8 libssl.so.7 libssl.so.6").split(' '));
+  bd::Array<bd::String> libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.1.0.1 libssl.so.1.0.0 libssl.so.0.9.8 libssl.so.10 libssl.so.9 libssl.so.8 libssl.so.7 libssl.so.6").split(' '));
 
   for (size_t i = 0; i < libs_list.length(); ++i) {
     dlerror(); // Clear Errors

+ 2 - 0
src/openssl.cc

@@ -121,9 +121,11 @@ int uninit_openssl () {
     RAND_write_file(tls_rand_file);
 #endif
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
   ERR_free_strings();
   EVP_cleanup();
   CRYPTO_cleanup_all_ex_data();
+#endif
 
   unload_libssl();
   unload_libcrypto();