diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-08-11 01:30:38 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-08-12 23:08:19 +0100 |
commit | e9c4caa8f4b5a004c56189a6f83395f809e8cbf8 (patch) | |
tree | b2847f96fc1c72463741caa31a10a7b1f67433eb /src/streams/openssl.c | |
parent | 806778dc482e40d26bc7a9d44ccd18b888f6ec33 (diff) | |
download | libgit2-ethomson/ssl_refactor.tar.gz |
openssl: dynamically load libssl and symbols (optionally)ethomson/ssl_refactor
Provide an interface around OpenSSL to dynamically load the libraries and symbols,
so that users can distribute a libgit2 library that is not linked directly against
OpenSSL. This enables users to target multiple distributions with a single binary.
This mechanism is optional and disabled by default. Configure cmake with
-DUSE_HTTPS=OpenSSL-Dynamic to use it.
Diffstat (limited to 'src/streams/openssl.c')
-rw-r--r-- | src/streams/openssl.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/streams/openssl.c b/src/streams/openssl.c index 95989341b..0dc400d32 100644 --- a/src/streams/openssl.c +++ b/src/streams/openssl.c @@ -7,6 +7,7 @@ #include "streams/openssl.h" #include "streams/openssl_legacy.h" +#include "streams/openssl_dynamic.h" #ifdef GIT_OPENSSL @@ -27,10 +28,12 @@ # include <netinet/in.h> #endif -#include <openssl/ssl.h> -#include <openssl/err.h> -#include <openssl/x509v3.h> -#include <openssl/bio.h> +#ifndef GIT_OPENSSL_DYNAMIC +# include <openssl/ssl.h> +# include <openssl/err.h> +# include <openssl/x509v3.h> +# include <openssl/bio.h> +#endif SSL_CTX *git__ssl_ctx; @@ -93,6 +96,11 @@ int git_openssl_stream_global_init(void) ssl_opts |= SSL_OP_NO_COMPRESSION; #endif +#ifdef GIT_OPENSSL_DYNAMIC + if (git_openssl_stream_dynamic_init() < 0) + return -1; +#endif + #ifdef VALGRIND /* Swap in our own allocator functions that initialize allocated memory */ if (!allocators_initialized && @@ -139,7 +147,7 @@ error: return -1; } -#ifndef GIT_OPENSSL_LEGACY +#if !defined(GIT_OPENSSL_LEGACY) && !defined(GIT_OPENSSL_DYNAMIC) int git_openssl_set_locking(void) { # ifdef GIT_THREADS |