attempt to check for default CA path
authorMichael Wallner <mike@php.net>
Thu, 24 Mar 2016 11:06:58 +0000 (12:06 +0100)
committerMichael Wallner <mike@php.net>
Thu, 24 Mar 2016 11:06:58 +0000 (12:06 +0100)
config9.m4
src/php_http_client_curl.c

index c95f007..176f0db 100644 (file)
@@ -409,20 +409,27 @@ dnl ----
 
                        dnl end compile tests
 
-                       AC_MSG_CHECKING([for bundled SSL CA info])
-                       CURL_CAINFO=
-                       for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-bundle.crt"; do
-                               if test -f "$i"; then
-                                       CURL_CAINFO="$i"
-                                       break
+                       AC_MSG_CHECKING([for default SSL CA info/path])
+                       for i in \
+                               "$($CURL_CONFIG --ca)" \
+                               /etc/ssl/certs \
+                               /etc/pki/tls/certs/ca-bundle.crt \
+                               /etc/ssl/certs/ca-bundle.crt \
+                               /etc/pki/tls/certs/ca-bundle.trust.crt \
+                               /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \
+                               /System/Library/OpenSSL
+                       do
+                               if test -d "$i"; then
+                                       # check if it's actually a hashed directory
+                                       if ls "$i"/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].0 >/dev/null 2>&1; then
+                                               AC_MSG_RESULT([capath: $i])
+                                               AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAPATH], ["$i"], [path to default SSL CA path])
+                                       fi
+                               elif test -e "$i"; then
+                                       AC_MSG_RESULT([cainfo: $i])
+                                       AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$i"], [path to default SSL CA info])
                                fi
                        done
-                       if test "x$CURL_CAINFO" = "x"; then
-                               AC_MSG_RESULT([not found])
-                       else
-                               AC_MSG_RESULT([$CURL_CAINFO])
-                               AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
-                       fi
 
                        PHP_ADD_INCLUDE($CURL_DIR/include)
                        PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
index f49aabc..567c3c6 100644 (file)
@@ -1483,6 +1483,9 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC)
                if ((opt = php_http_option_register(registry, ZEND_STRL("capath"), CURLOPT_CAPATH, IS_STRING))) {
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
+#ifdef PHP_HTTP_CURL_CAPATH
+                       ZVAL_STRING(&opt->defval, PHP_HTTP_CURL_CAPATH, 0);
+#endif
                }
                if ((opt = php_http_option_register(registry, ZEND_STRL("random_file"), CURLOPT_RANDOM_FILE, IS_STRING))) {
                        opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;