|
|
@@ -25,6 +25,7 @@
|
|
|
*/
|
|
|
|
|
|
|
|
|
+#include "buildinfo.h"
|
|
|
#include "common.h"
|
|
|
#include "main.h"
|
|
|
#include "dl.h"
|
|
|
@@ -37,7 +38,7 @@
|
|
|
#ifndef OPENSSL_SHLIB_VERSION
|
|
|
#define OPENSSL_SHLIB_VERSION_STR SHLIB_VERSION_NUMBER
|
|
|
#else
|
|
|
-#define OPENSSL_SHLIB_VERSION_STR STRINGIFY(OPENSSL_SHLIB_VERSION)
|
|
|
+#define OPENSSL_SHLIB_VERSION_STR __XSTRING(OPENSSL_SHLIB_VERSION)
|
|
|
#endif
|
|
|
|
|
|
void *libssl_handle = NULL;
|
|
|
@@ -58,8 +59,15 @@ static int load_symbols(void *handle) {
|
|
|
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(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
+#if defined(LIBRESSL_VERSION_NUMBER)
|
|
|
+ /* SSL_library_init: always symbol in LibreSSL. */
|
|
|
+ DLSYM_GLOBAL(handle, SSL_library_init);
|
|
|
+ /* SSL_load_error_strings: always symbol in LibreSSL. */
|
|
|
+ DLSYM_GLOBAL(handle, SSL_load_error_strings);
|
|
|
+#elif OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
+ /* SSL_library_init: symbol in LibreSSL and 1.0. Macro in 1.1+. */
|
|
|
DLSYM_GLOBAL_FWDCOMPAT(handle, SSL_library_init);
|
|
|
+ /* SSL_load_error_strings: Symbol in LibreSSL and 1.0. Macro in 1.1+. */
|
|
|
DLSYM_GLOBAL_FWDCOMPAT(handle, SSL_load_error_strings);
|
|
|
/* Some forward-compat is handled in src/compat/openssl.cc. */
|
|
|
#else
|
|
|
@@ -67,9 +75,18 @@ static int load_symbols(void *handle) {
|
|
|
DLSYM_GLOBAL(handle, OPENSSL_init_ssl);
|
|
|
#endif
|
|
|
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
|
|
|
- DLSYM_GLOBAL(handle, TLS_client_method);
|
|
|
+ /* Macro in 1.0 and LibreSSL. Symbol in 1.1+. */
|
|
|
DLSYM_GLOBAL(handle, SSL_CTX_set_options);
|
|
|
+#endif
|
|
|
+#if (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER > 0x20020002L) || \
|
|
|
+ (!defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L)
|
|
|
+ /* Not in 1.0. Symbol in 1.1+ and LibreSSL 2.2+ 0x20020002L. */
|
|
|
+ DLSYM_GLOBAL(handle, TLS_client_method);
|
|
|
+#elif defined(LIBRESSL_VERSION_NUMBER)
|
|
|
+ /* LibreSSL always has a symbol and not a macro to TLS_client_method. */
|
|
|
+ DLSYM_GLOBAL(handle, SSLv23_client_method);
|
|
|
#else
|
|
|
+ /* Symbol in 1.0 and LibreSSL. Macro in OpenSSL 1.1+. */
|
|
|
DLSYM_GLOBAL_FWDCOMPAT(handle, SSLv23_client_method);
|
|
|
/* Some forward-compat is handled in src/compat/openssl.cc. */
|
|
|
#endif
|
|
|
@@ -85,7 +102,12 @@ int load_libssl() {
|
|
|
|
|
|
sdprintf("Loading libssl");
|
|
|
|
|
|
- const auto& libs_list(bd::String("libssl.so." OPENSSL_SHLIB_VERSION_STR " "
|
|
|
+ const auto& libs_list(bd::String(
|
|
|
+#if !defined(LIBRESSL_VERSION_NUMBER)
|
|
|
+ SSL_LIBDIR "/libssl.so." OPENSSL_SHLIB_VERSION_STR " "
|
|
|
+ "libssl.so." OPENSSL_SHLIB_VERSION_STR " "
|
|
|
+#endif
|
|
|
+ SSL_LIBDIR "/libssl.so "
|
|
|
"libssl.so "
|
|
|
"libssl.so.12 "
|
|
|
"libssl.so.30 "
|
|
|
@@ -114,7 +136,7 @@ int load_libssl() {
|
|
|
}
|
|
|
|
|
|
if (load_symbols(libssl_handle)) {
|
|
|
- fprintf(stderr, STR("Missing symbols for libssl (likely too old)\n"));
|
|
|
+ fprintf(stderr, STR("\nMissing symbols for libssl (likely too old)\n"));
|
|
|
return(1);
|
|
|
}
|
|
|
|