- implement ssl crypto locks
authorMichael Wallner <mike@php.net>
Thu, 8 Sep 2005 18:07:10 +0000 (18:07 +0000)
committerMichael Wallner <mike@php.net>
Thu, 8 Sep 2005 18:07:10 +0000 (18:07 +0000)
config.m4
config.w32
http.c

index 5201be6bb5a47e5a57dd6411c86225ba6372d799..62dcb4f04b1a116be03684e41424d43a920444db 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -61,6 +61,12 @@ dnl ----
                        AC_MSG_RESULT([found: $CURL_CONFIG])
                fi
                
+               CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
+               if test CURL_SSL == "SSL"; then
+                       AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
+               fi
+               AC_CHECK_HEADERS([openssl/crypto.h])
+               
                CURL_LIBS=`$CURL_CONFIG --libs`
                
                PHP_ADD_INCLUDE($CURL_DIR/include)
index 134429c144037826102c74582e36eb4112f87228..11824384a2d02098dae4a5e8634bde6f00fef6a1 100644 (file)
@@ -36,6 +36,7 @@ if (PHP_HTTP != "no") {
                        CHECK_LIB("zlib.lib", "http", PHP_HTTP) &&
                        CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {
                AC_DEFINE("HTTP_HAVE_CURL", 1, "Have CURL library");
+               AC_DEFINE("HTTP_HAVE_SSL", 1, "Have SSL");
                AC_DEFINE("HAVE_CURL_MULTI_STRERROR", 1, "");
                AC_DEFINE("HAVE_CURL_EASY_STRERROR", 1, "")
        } else {
diff --git a/http.c b/http.c
index 02a789adab5ba688710065a576f9faa6fd468d10..06c32241e66db349246e829a5be613a0ca9d2cb7 100644 (file)
--- a/http.c
+++ b/http.c
 #include "phpstr/phpstr.h"
 
 #ifdef HTTP_HAVE_CURL
+#      if defined(ZTS) && defined(HTTP_HAVE_SSL)
+#              if !defined(HAVE_OPENSSL_CRYPTO_H)
+#                      error "libcurl was compiled with OpenSSL support, but we have no crypto.h"
+#              else
+#                      define HTTP_NEED_SSL
+#                      include <openssl/crypto.h>
+#              endif
+#      endif
 #      ifdef PHP_WIN32
 #              include <winsock2.h>
 #      endif
@@ -251,9 +259,7 @@ PHP_INI_END()
 /* }}} */
 
 /* {{{ SSL */
-#if defined(ZTS) && defined(HTTP_HAVE_CURL) && defined(HAVE_OPENSSL_CRYPTO_H)
-
-#include <openssl/crypto.h>
+#ifdef HTTP_NEED_SSL
 
 static MUTEX_T *http_ssl_mutex = NULL;
 
@@ -310,7 +316,7 @@ PHP_MINIT_FUNCTION(http)
 
 #ifdef HTTP_HAVE_CURL
        if (CURLE_OK == curl_global_init(CURL_GLOBAL_ALL)) {
-#      if defined(ZTS) && defined(HAVE_OPENSSL_CRYPTO_H)
+#      ifdef HTTP_NEED_SSL
                curl_version_info_data *cvid = curl_version_info(CURLVERSION_NOW);
                if (cvid && (cvid->features & CURL_VERSION_SSL)) {
                        http_ssl_init();
@@ -344,7 +350,7 @@ PHP_MSHUTDOWN_FUNCTION(http)
        UNREGISTER_INI_ENTRIES();
 #ifdef HTTP_HAVE_CURL
        curl_global_cleanup();
-#      if defined(ZTS) && defined(HAVE_OPENSSL_CRYPTO_H)
+#      ifdef HTTP_NEED_SSL
        if (http_ssl_mutex) {
                http_ssl_cleanup();
        }