You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2019/06/23 22:15:31 UTC

svn commit: r1861951 - in /apr/apr/trunk: CMakeLists.txt build.conf crypto/apr_crypto.c crypto/apr_crypto_internal.c crypto/apr_crypto_openssl.c include/private/apr_crypto_internal.h

Author: minfrin
Date: Sun Jun 23 22:15:31 2019
New Revision: 1861951

URL: http://svn.apache.org/viewvc?rev=1861951&view=rev
Log:
Revert r1833421 et al:

Move OpenSSL initialisation back to apr_crypto_openssl, reinstate
DSO support.

Removed:
    apr/apr/trunk/crypto/apr_crypto_internal.c
Modified:
    apr/apr/trunk/CMakeLists.txt
    apr/apr/trunk/build.conf
    apr/apr/trunk/crypto/apr_crypto.c
    apr/apr/trunk/crypto/apr_crypto_openssl.c
    apr/apr/trunk/include/private/apr_crypto_internal.h

Modified: apr/apr/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CMakeLists.txt?rev=1861951&r1=1861950&r2=1861951&view=diff
==============================================================================
--- apr/apr/trunk/CMakeLists.txt (original)
+++ apr/apr/trunk/CMakeLists.txt Sun Jun 23 22:15:31 2019
@@ -259,7 +259,6 @@ SET(APR_SOURCES
   buckets/apr_buckets_socket.c
   crypto/apr_crypto.c
   crypto/apr_crypto_prng.c
-  crypto/apr_crypto_internal.c
   crypto/apr_md4.c
   crypto/apr_md5.c
   crypto/apr_passwd.c

Modified: apr/apr/trunk/build.conf
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build.conf?rev=1861951&r1=1861950&r2=1861951&view=diff
==============================================================================
--- apr/apr/trunk/build.conf (original)
+++ apr/apr/trunk/build.conf Sun Jun 23 22:15:31 2019
@@ -12,7 +12,6 @@ paths =
   buckets/*.c
   crypto/apr_crypto.c
   crypto/apr_crypto_prng.c
-  crypto/apr_crypto_internal.c
   crypto/apr_md4.c
   crypto/apr_md5.c
   crypto/apr_passwd.c

Modified: apr/apr/trunk/crypto/apr_crypto.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_crypto.c?rev=1861951&r1=1861950&r2=1861951&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_crypto.c (original)
+++ apr/apr/trunk/crypto/apr_crypto.c Sun Jun 23 22:15:31 2019
@@ -379,14 +379,7 @@ APR_DECLARE(apr_status_t) apr_crypto_lib
                                                  const char **version)
 {
     apr_status_t rv = APR_ENOTIMPL;
-#if APU_HAVE_OPENSSL
-    if (!strcmp(name, "openssl")) {
-        *version = apr__crypto_openssl_version();
-        rv = *version ? APR_SUCCESS : APR_NOTFOUND;
-    }
-    else
-#endif
-    ;
+
     return rv;
 }
 
@@ -434,16 +427,6 @@ APR_DECLARE(apr_status_t) apr_crypto_lib
     }
 
     rv = APR_ENOTIMPL;
-#if APU_HAVE_OPENSSL
-    if (!strcmp(name, "openssl")) {
-        rv = apr__crypto_openssl_init(params, result, pool);
-        if (rv == APR_SUCCESS) {
-            lib->term = apr__crypto_openssl_term;
-            lib->name = "openssl";
-        }
-    }
-    else
-#endif
     ;
     if (rv == APR_SUCCESS) {
         lib->pool = pool;
@@ -473,12 +456,6 @@ static apr_status_t crypto_lib_term(cons
     }
 
     rv = APR_ENOTIMPL;
-#if APU_HAVE_OPENSSL
-    if (!strcmp(name, "openssl")) {
-        rv = APR_SUCCESS;
-    }
-    else
-#endif
     ;
     if (rv == APR_SUCCESS) {
         apr_pool_cleanup_kill(lib->pool, lib, crypto_lib_cleanup);

Modified: apr/apr/trunk/crypto/apr_crypto_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_crypto_openssl.c?rev=1861951&r1=1861950&r2=1861951&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_crypto_openssl.c (original)
+++ apr/apr/trunk/crypto/apr_crypto_openssl.c Sun Jun 23 22:15:31 2019
@@ -26,6 +26,7 @@
 #include "apr_strings.h"
 #include "apr_time.h"
 #include "apr_buckets.h"
+#include "apr_thread_mutex.h"
 
 #include "apr_crypto_internal.h"
 
@@ -36,9 +37,28 @@
 #include <openssl/engine.h>
 #include <openssl/crypto.h>
 #include <openssl/obj_mac.h> /* for NID_* */
+#include <openssl/conf.h>
+#include <openssl/comp.h>
+#include <openssl/ssl.h>
 
 #define LOG_PREFIX "apr_crypto_openssl: "
 
+#ifndef APR_USE_OPENSSL_PRE_1_1_API
+#if defined(LIBRESSL_VERSION_NUMBER)
+/* LibreSSL declares OPENSSL_VERSION_NUMBER == 2.0 but does not necessarily
+ * include changes from OpenSSL >= 1.1 (new functions, macros, * deprecations,
+ * ...), so we have to work around this...
+ */
+#define APR_USE_OPENSSL_PRE_1_0_API     (0)
+#define APR_USE_OPENSSL_PRE_1_1_API     (LIBRESSL_VERSION_NUMBER < 0x2070000f)
+#define APR_USE_OPENSSL_PRE_1_1_1_API   (1)
+#else  /* defined(LIBRESSL_VERSION_NUMBER) */
+#define APR_USE_OPENSSL_PRE_1_0_API     (OPENSSL_VERSION_NUMBER < 0x10000000L)
+#define APR_USE_OPENSSL_PRE_1_1_API     (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#define APR_USE_OPENSSL_PRE_1_1_1_API   (OPENSSL_VERSION_NUMBER < 0x10101000L)
+#endif /* defined(LIBRESSL_VERSION_NUMBER) */
+#endif /* ndef APR_USE_OPENSSL_PRE_1_1_API */
+
 struct apr_crypto_t {
     apr_pool_t *pool;
     const apr_crypto_driver_t *provider;
@@ -133,7 +153,15 @@ static apr_status_t crypto_error(const a
  */
 static apr_status_t crypto_shutdown(void)
 {
-    return apr_crypto_lib_term("openssl");
+    ERR_free_strings();
+    EVP_cleanup();
+    ENGINE_cleanup();
+    return APR_SUCCESS;
+}
+
+static apr_status_t crypto_shutdown_helper(void *data)
+{
+    return crypto_shutdown();
 }
 
 /**
@@ -142,7 +170,21 @@ static apr_status_t crypto_shutdown(void
 static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
         const apu_err_t **result)
 {
-    return apr_crypto_lib_init("openssl", params, result, pool);
+#if APR_USE_OPENSSL_PRE_1_1_API
+    (void)CRYPTO_malloc_init();
+#else
+    OPENSSL_malloc_init();
+#endif
+    ERR_load_crypto_strings();
+    /* SSL_load_error_strings(); */
+    OpenSSL_add_all_algorithms();
+    ENGINE_load_builtin_engines();
+    ENGINE_register_all_complete();
+
+    apr_pool_cleanup_register(pool, pool, crypto_shutdown_helper,
+            apr_pool_cleanup_null);
+
+    return APR_SUCCESS;
 }
 
 #if OPENSSL_VERSION_NUMBER < 0x0090802fL

Modified: apr/apr/trunk/include/private/apr_crypto_internal.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/private/apr_crypto_internal.h?rev=1861951&r1=1861950&r2=1861951&view=diff
==============================================================================
--- apr/apr/trunk/include/private/apr_crypto_internal.h (original)
+++ apr/apr/trunk/include/private/apr_crypto_internal.h Sun Jun 23 22:15:31 2019
@@ -402,32 +402,6 @@ struct apr_crypto_driver_t {
 
 };
 
-#if APU_HAVE_OPENSSL
-#include <openssl/crypto.h>
-
-#ifndef APR_USE_OPENSSL_PRE_1_1_API
-#if defined(LIBRESSL_VERSION_NUMBER)
-/* LibreSSL declares OPENSSL_VERSION_NUMBER == 2.0 but does not necessarily
- * include changes from OpenSSL >= 1.1 (new functions, macros, * deprecations,
- * ...), so we have to work around this...
- */
-#define APR_USE_OPENSSL_PRE_1_0_API     (0)
-#define APR_USE_OPENSSL_PRE_1_1_API     (LIBRESSL_VERSION_NUMBER < 0x2070000f)
-#define APR_USE_OPENSSL_PRE_1_1_1_API   (1)
-#else  /* defined(LIBRESSL_VERSION_NUMBER) */
-#define APR_USE_OPENSSL_PRE_1_0_API     (OPENSSL_VERSION_NUMBER < 0x10000000L)
-#define APR_USE_OPENSSL_PRE_1_1_API     (OPENSSL_VERSION_NUMBER < 0x10100000L)
-#define APR_USE_OPENSSL_PRE_1_1_1_API   (OPENSSL_VERSION_NUMBER < 0x10101000L)
-#endif /* defined(LIBRESSL_VERSION_NUMBER) */
-#endif /* ndef APR_USE_OPENSSL_PRE_1_1_API */
-
-const char *apr__crypto_openssl_version(void);
-apr_status_t apr__crypto_openssl_init(const char *params,
-                                      const apu_err_t **result,
-                                      apr_pool_t *pool);
-apr_status_t apr__crypto_openssl_term(void);
-#endif
-
 #endif
 
 #ifdef __cplusplus