summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2019-06-23 22:49:52 +0000
committerGraham Leggett <minfrin@apache.org>2019-06-23 22:49:52 +0000
commit741c00a112a4419e65616260101d8026e69effa6 (patch)
tree4dc23367f9d71b346fcef09d55f3ebc4b27356b4 /crypto
parent39f444510548b97f6e46e16df675bdce5f943920 (diff)
downloadapr-741c00a112a4419e65616260101d8026e69effa6.tar.gz
apr_crypto_openssl: use OPENSSL_init_crypto() to initialise OpenSSL
on versions 1.1+. Reference: http://openssl.6102.n7.nabble.com/Shutting-down-openssl-is-the-correct-thing-to-do-nothing-td76857.html#a76862 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1861954 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'crypto')
-rw-r--r--crypto/apr_crypto_openssl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/apr_crypto_openssl.c b/crypto/apr_crypto_openssl.c
index 7a9c40459..169ccf31d 100644
--- a/crypto/apr_crypto_openssl.c
+++ b/crypto/apr_crypto_openssl.c
@@ -153,9 +153,21 @@ static apr_status_t crypto_error(const apu_err_t **result,
*/
static apr_status_t crypto_shutdown(void)
{
+#if HAVE_OPENSSL_INIT_SSL
+ /* Openssl v1.1+ handles all termination automatically. Do
+ * nothing in this case.
+ */
+
+#else
+ /* Termination below is for legacy Openssl versions v1.0.x and
+ * older.
+ */
+
ERR_free_strings();
EVP_cleanup();
ENGINE_cleanup();
+#endif
+
return APR_SUCCESS;
}
@@ -170,6 +182,19 @@ static apr_status_t crypto_shutdown_helper(void *data)
static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
const apu_err_t **result)
{
+#if HAVE_DECL_OPENSSL_INIT_CRYPTO
+ /* Openssl v1.1+ handles all initialisation automatically, apart
+ * from hints as to how we want to use the library.
+ *
+ * We tell openssl we want to include engine support.
+ */
+ OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
+
+#else
+ /* Configuration below is for legacy versions Openssl v1.0 and
+ * older.
+ */
+
#if APR_USE_OPENSSL_PRE_1_1_API
(void)CRYPTO_malloc_init();
#else
@@ -180,6 +205,7 @@ static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
OpenSSL_add_all_algorithms();
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
+#endif
apr_pool_cleanup_register(pool, pool, crypto_shutdown_helper,
apr_pool_cleanup_null);