streams: openssl: provide `OPENSSL_init_ssl` for legacy API In order to further avoid using ifdef's in our code flow, provide the function `OPENSSL_init_ssl` in case we are using the legacy OpenSSL API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/src/streams/openssl.c b/src/streams/openssl.c
index 31c0824..8223d58 100644
--- a/src/streams/openssl.c
+++ b/src/streams/openssl.c
@@ -47,9 +47,18 @@ SSL_CTX *git__ssl_ctx;
* OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
* which do not exist in previous versions. We define these inline functions so
* we can program against the interface instead of littering the implementation
- * with ifdefs.
+ * with ifdefs. We do the same for OPENSSL_init_ssl.
*/
#if defined(OPENSSL_LEGACY_API)
+static int OPENSSL_init_ssl(int opts, void *settings)
+{
+ GIT_UNUSED(opts);
+ GIT_UNUSED(settings);
+ SSL_load_error_strings();
+ OpenSSL_add_ssl_algorithms();
+ return 0;
+}
+
static BIO_METHOD* BIO_meth_new(int type, const char *name)
{
BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
@@ -202,12 +211,7 @@ int git_openssl_stream_global_init(void)
ssl_opts |= SSL_OP_NO_COMPRESSION;
#endif
-#if defined(OPENSSL_LEGACY_API)
- SSL_load_error_strings();
- OpenSSL_add_ssl_algorithms();
-#else
OPENSSL_init_ssl(0, NULL);
-#endif
/*
* Load SSLv{2,3} and TLSv1 so that we can talk with servers