]> The Tcpdump Group git mirrors - libpcap/commitdiff
sslutils: handle routines removed in at least some OpenSSL libraries.
authorGuy Harris <[email protected]>
Thu, 29 Jun 2023 23:16:10 +0000 (16:16 -0700)
committerGuy Harris <[email protected]>
Thu, 29 Jun 2023 23:16:10 +0000 (16:16 -0700)
The Shiny New OpenSSL 3.0.8 on the AppVeyor images with Visual Studio
2019 and later are missing some routines that have, apparently, been
deprecated since 1.1.0.  If we have OpenSSL 1.1.0 or later, use the
replacements.

sslutils.c

index 7274cc34c580bdf1bfe740c618ff318d4c0f7de7..68ced77985f677ae4c6159250dace2c3e9171641 100644 (file)
@@ -64,14 +64,32 @@ int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t er
        static int inited = 0;
        if (inited) return 0;
 
+       /*
+        * Avoid deprecated routines, even if they're still documented,
+        * as random versions of OpenSSL might not make them available.
+        * XXX - what's the minimum OpenSSL version we should support?
+        * And what about libressl?
+        */
+#if defined(OPENSSL_VERSION_NUMBER) >= 0x10100000L
+       /* 1.1.0 or later */
+       OPENSSL_init_ssl(0, NULL);
+       OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
+#else
        SSL_library_init();
        SSL_load_error_strings();
+#endif
        OpenSSL_add_ssl_algorithms();
        if (enable_compression)
                SSL_COMP_get_compression_methods();
 
+#if defined(OPENSSL_VERSION_NUMBER) >= 0x10100000L
+       /* 1.1.0 or later */
+       SSL_METHOD const *meth =
+           is_server ? TLS_server_method() : TLS_client_method();
+#else
        SSL_METHOD const *meth =
            is_server ? SSLv23_server_method() : SSLv23_client_method();
+#endif
        ctx = SSL_CTX_new(meth);
        if (! ctx)
        {