@@ -38,15 +38,18 @@ SSL_CTX *git__ssl_ctx;
3838
3939#define GIT_SSL_DEFAULT_CIPHERS "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES128-SHA256:DHE-DSS-AES256-SHA256:DHE-DSS-AES128-SHA:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA"
4040
41+ #if (defined(OPENSSL_VERSION_NUMBER ) && OPENSSL_VERSION_NUMBER < 0x10100000L ) || \
42+ (defined(LIBRESSL_VERSION_NUMBER ) && LIBRESSL_VERSION_NUMBER < 0x20700000L )
43+ # define OPENSSL_LEGACY_API
44+ #endif
45+
4146/*
4247 * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
4348 * which do not exist in previous versions. We define these inline functions so
4449 * we can program against the interface instead of littering the implementation
4550 * with ifdefs.
4651 */
47- #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
48- (defined(LIBRESSL_VERSION_NUMBER ) && LIBRESSL_VERSION_NUMBER < 0x20700000L )
49-
52+ #if defined(OPENSSL_LEGACY_API )
5053static BIO_METHOD * BIO_meth_new (int type , const char * name )
5154{
5255 BIO_METHOD * meth = git__calloc (1 , sizeof (BIO_METHOD ));
@@ -134,10 +137,7 @@ static const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
134137 return ASN1_STRING_data ((ASN1_STRING * )x );
135138}
136139
137- #endif
138-
139- #if defined(GIT_THREADS ) && OPENSSL_VERSION_NUMBER < 0x10100000L
140-
140+ # if defined(GIT_THREADS )
141141static git_mutex * openssl_locks ;
142142
143143static void openssl_locking_function (
@@ -168,8 +168,8 @@ static void shutdown_ssl_locking(void)
168168 git_mutex_free (& openssl_locks [i ]);
169169 git__free (openssl_locks );
170170}
171-
172- #endif /* GIT_THREADS && OPENSSL_VERSION_NUMBER < 0x10100000L */
171+ # endif /* GIT_THREADS */
172+ #endif /* OPENSSL_LEGACY_API */
173173
174174static BIO_METHOD * git_stream_bio_method ;
175175static int init_bio_method (void );
@@ -202,8 +202,7 @@ int git_openssl_stream_global_init(void)
202202 ssl_opts |= SSL_OP_NO_COMPRESSION ;
203203#endif
204204
205- #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
206- (defined(LIBRESSL_VERSION_NUMBER ) && LIBRESSL_VERSION_NUMBER < 0x20700000L )
205+ #if defined(OPENSSL_LEGACY_API )
207206 SSL_load_error_strings ();
208207 OpenSSL_add_ssl_algorithms ();
209208#else
@@ -258,7 +257,7 @@ static void threadid_cb(CRYPTO_THREADID *threadid)
258257
259258int git_openssl_set_locking (void )
260259{
261- #if defined(GIT_THREADS ) && OPENSSL_VERSION_NUMBER < 0x10100000L
260+ #if defined(GIT_THREADS ) && defined( OPENSSL_LEGACY_API )
262261 int num_locks , i ;
263262
264263 CRYPTO_THREADID_set_callback (threadid_cb );
@@ -277,7 +276,7 @@ int git_openssl_set_locking(void)
277276 CRYPTO_set_locking_callback (openssl_locking_function );
278277 git__on_shutdown (shutdown_ssl_locking );
279278 return 0 ;
280- #elif OPENSSL_VERSION_NUMBER >= 0x10100000L
279+ #elif !defined( OPENSSL_LEGACY_API )
281280 return 0 ;
282281#else
283282 giterr_set (GITERR_THREAD , "libgit2 was not built with threads" );
0 commit comments