Skip to content

Commit dd9de88

Browse files
committed
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 parent ede63b9 commit dd9de88

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/streams/openssl.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,18 @@ SSL_CTX *git__ssl_ctx;
4747
* OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
4848
* which do not exist in previous versions. We define these inline functions so
4949
* we can program against the interface instead of littering the implementation
50-
* with ifdefs.
50+
* with ifdefs. We do the same for OPENSSL_init_ssl.
5151
*/
5252
#if defined(OPENSSL_LEGACY_API)
53+
static int OPENSSL_init_ssl(int opts, void *settings)
54+
{
55+
GIT_UNUSED(opts);
56+
GIT_UNUSED(settings);
57+
SSL_load_error_strings();
58+
OpenSSL_add_ssl_algorithms();
59+
return 0;
60+
}
61+
5362
static BIO_METHOD* BIO_meth_new(int type, const char *name)
5463
{
5564
BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
@@ -202,12 +211,7 @@ int git_openssl_stream_global_init(void)
202211
ssl_opts |= SSL_OP_NO_COMPRESSION;
203212
#endif
204213

205-
#if defined(OPENSSL_LEGACY_API)
206-
SSL_load_error_strings();
207-
OpenSSL_add_ssl_algorithms();
208-
#else
209214
OPENSSL_init_ssl(0, NULL);
210-
#endif
211215

212216
/*
213217
* Load SSLv{2,3} and TLSv1 so that we can talk with servers

0 commit comments

Comments
 (0)