From 1765b4b766fef54707db83a918bde9acbda79f4d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 6 Jun 2018 01:53:04 +0200 Subject: Make compatible with a pure OpenSSL 1.1.0 API, ... ...when deprecated functions are disabled, for instance, through -DOPENSSL_API_COMPAT=0x10100000L. --- configure.ac | 2 +- socket.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0bbb30ad..ebfd7554 100644 --- a/configure.ac +++ b/configure.ac @@ -786,7 +786,7 @@ then save_LIBS="$LIBS" for i in "" "-ldl" ; do LIBS="$LDFLAGS $save_LIBS $i" - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ],[SSL_library_init()])],[found=1; break]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ],[SSL_connect((SSL *)0)])],[found=1; break]) done if test $found = 0 ; then AC_MSG_RESULT([error]) diff --git a/socket.c b/socket.c index f836115f..bcf06491 100644 --- a/socket.c +++ b/socket.c @@ -954,8 +954,10 @@ static int OSSL10X_proto_version_logic(int sock, const char **myproto, int *avoi return 0; } #define OSSL_proto_version_logic(a,b,c) OSSL10X_proto_version_logic((a),(b),(c)) +#undef OSSL110_API #else /* implementation for OpenSSL 1.1.0 */ +#define OSSL110_API 1 static int OSSL110_proto_version_logic(int sock, const char **myproto, int *avoid_ssl_versions) { @@ -1049,11 +1051,16 @@ int SSLOpen(int sock, char *mycert, char *mykey, const char *myproto, int certck int ssle_connect = 0; long ver; +#ifndef OSSL110_API SSL_load_error_strings(); SSL_library_init(); OpenSSL_add_all_algorithms(); /* see Debian Bug#576430 and manpage */ + ver = SSLeay(); +#else + ver = OpenSSL_version_num(); +#endif - if ((ver = SSLeay()) < OPENSSL_VERSION_NUMBER) { + if (ver < OPENSSL_VERSION_NUMBER) { report(stderr, GT_("Loaded OpenSSL library %#lx older than headers %#lx, refusing to work.\n"), (long)ver, (long)(OPENSSL_VERSION_NUMBER)); return -1; } -- cgit v1.2.3