Skip to content

Commit 29081c2

Browse files
committed
openssl_stream: remove locking initialization on OpenSSL version >=1.1
Up to version 1.0, OpenSSL required us to provide a callback which implements a locking mechanism. Due to problems in the API design though this mechanism was inherently broken, especially regarding that the locking callback cannot report errors in an obvious way. Due to this shortcoming, the locking initialization has been completely removed in OpenSSL version 1.1. As the library has also been refactored to not make any use of these callback functions, we can safely remove all initialization of the locking subsystem if compiling against OpenSSL version 1.1 or higher. This fixes a compilation error when compiling against OpenSSL version 1.1 which has been built without stubs for deprecated syntax.
1 parent e572b63 commit 29081c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/openssl_stream.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SSL_CTX *git__ssl_ctx;
3737

3838
#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"
3939

40-
#ifdef GIT_THREADS
40+
#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L
4141

4242
static git_mutex *openssl_locks;
4343

@@ -70,7 +70,7 @@ static void shutdown_ssl_locking(void)
7070
git__free(openssl_locks);
7171
}
7272

73-
#endif /* GIT_THREADS */
73+
#endif /* GIT_THREADS && OPENSSL_VERSION_NUMBER < 0x10100000L */
7474

7575
static BIO_METHOD *git_stream_bio_method;
7676
static int init_bio_method(void);
@@ -146,7 +146,7 @@ int git_openssl_stream_global_init(void)
146146

147147
int git_openssl_set_locking(void)
148148
{
149-
#ifdef GIT_THREADS
149+
#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L
150150
int num_locks, i;
151151

152152
num_locks = CRYPTO_num_locks();
@@ -163,6 +163,8 @@ int git_openssl_set_locking(void)
163163
CRYPTO_set_locking_callback(openssl_locking_function);
164164
git__on_shutdown(shutdown_ssl_locking);
165165
return 0;
166+
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
167+
return 0;
166168
#else
167169
giterr_set(GITERR_THREAD, "libgit2 was not built with threads");
168170
return -1;

0 commit comments

Comments
 (0)