| 1 | Index: wp-includes/cron.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/cron.php (revision 10446) |
|---|
| 4 | +++ wp-includes/cron.php (working copy) |
|---|
| 5 | @@ -201,7 +201,7 @@ |
|---|
| 6 | |
|---|
| 7 | update_option( 'doing_cron', $local_time + 30 ); |
|---|
| 8 | |
|---|
| 9 | - wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false)); |
|---|
| 10 | + wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))); |
|---|
| 11 | } |
|---|
| 12 | |
|---|
| 13 | /** |
|---|
| 14 | Index: wp-includes/http.php |
|---|
| 15 | =================================================================== |
|---|
| 16 | --- wp-includes/http.php (revision 10446) |
|---|
| 17 | +++ wp-includes/http.php (working copy) |
|---|
| 18 | @@ -237,10 +237,10 @@ |
|---|
| 19 | } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { |
|---|
| 20 | $working_transport['streams'] = new WP_Http_Streams(); |
|---|
| 21 | $blocking_transport[] = &$working_transport['streams']; |
|---|
| 22 | - } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) { |
|---|
| 23 | + } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { |
|---|
| 24 | $working_transport['fopen'] = new WP_Http_Fopen(); |
|---|
| 25 | $blocking_transport[] = &$working_transport['fopen']; |
|---|
| 26 | - } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { |
|---|
| 27 | + } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { |
|---|
| 28 | $working_transport['fsockopen'] = new WP_Http_Fsockopen(); |
|---|
| 29 | $blocking_transport[] = &$working_transport['fsockopen']; |
|---|
| 30 | } |
|---|
| 31 | @@ -282,15 +282,18 @@ |
|---|
| 32 | if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { |
|---|
| 33 | $working_transport['exthttp'] = new WP_Http_ExtHttp(); |
|---|
| 34 | $blocking_transport[] = &$working_transport['exthttp']; |
|---|
| 35 | + } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { |
|---|
| 36 | + $working_transport['curl'] = new WP_Http_Curl(); |
|---|
| 37 | + $blocking_transport[] = &$working_transport['curl']; |
|---|
| 38 | } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { |
|---|
| 39 | $working_transport['streams'] = new WP_Http_Streams(); |
|---|
| 40 | $blocking_transport[] = &$working_transport['streams']; |
|---|
| 41 | - } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { |
|---|
| 42 | + } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { |
|---|
| 43 | $working_transport['fsockopen'] = new WP_Http_Fsockopen(); |
|---|
| 44 | $blocking_transport[] = &$working_transport['fsockopen']; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | - foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) { |
|---|
| 48 | + foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) { |
|---|
| 49 | if ( isset($working_transport[$transport]) ) |
|---|
| 50 | $nonblocking_transport[] = &$working_transport[$transport]; |
|---|
| 51 | } |
|---|
| 52 | @@ -358,17 +361,27 @@ |
|---|
| 53 | 'timeout' => apply_filters( 'http_request_timeout', 5), |
|---|
| 54 | 'redirection' => apply_filters( 'http_request_redirection_count', 5), |
|---|
| 55 | 'httpversion' => apply_filters( 'http_request_version', '1.0'), |
|---|
| 56 | - 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ), |
|---|
| 57 | + 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), |
|---|
| 58 | 'blocking' => true, |
|---|
| 59 | 'headers' => array(), |
|---|
| 60 | 'body' => null, |
|---|
| 61 | 'compress' => false, |
|---|
| 62 | - 'decompress' => true |
|---|
| 63 | + 'decompress' => true, |
|---|
| 64 | + 'sslverify' => true |
|---|
| 65 | ); |
|---|
| 66 | |
|---|
| 67 | $r = wp_parse_args( $args, $defaults ); |
|---|
| 68 | $r = apply_filters( 'http_request_args', $r, $url ); |
|---|
| 69 | |
|---|
| 70 | + $arrURL = parse_url($url); |
|---|
| 71 | + |
|---|
| 72 | + // Determine if this is a https call and pass that on to the transport functions |
|---|
| 73 | + // so that we can blacklist the transports that do not support ssl verification |
|---|
| 74 | + if ( $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl' ) |
|---|
| 75 | + $r['ssl'] = true; |
|---|
| 76 | + else |
|---|
| 77 | + $r['ssl'] = false; |
|---|
| 78 | + |
|---|
| 79 | if ( is_null( $r['headers'] ) ) |
|---|
| 80 | $r['headers'] = array(); |
|---|
| 81 | |
|---|
| 82 | @@ -927,7 +940,8 @@ |
|---|
| 83 | 'max_redirects' => $r['redirection'], |
|---|
| 84 | 'protocol_version' => (float) $r['httpversion'], |
|---|
| 85 | 'header' => $strHeaders, |
|---|
| 86 | - 'timeout' => $r['timeout'] |
|---|
| 87 | + 'timeout' => $r['timeout'], |
|---|
| 88 | + 'verify_peer' => apply_filters('https_ssl_verify', $r['sslverify']) |
|---|
| 89 | ) |
|---|
| 90 | ); |
|---|
| 91 | |
|---|
| 92 | @@ -1060,6 +1074,10 @@ |
|---|
| 93 | 'redirect' => $r['redirection'], |
|---|
| 94 | 'useragent' => $r['user-agent'], |
|---|
| 95 | 'headers' => $r['headers'], |
|---|
| 96 | + 'ssl' => array( |
|---|
| 97 | + 'verifypeer' => apply_filters('https_ssl_verify', $r['sslverify']), |
|---|
| 98 | + 'verifyhost' => apply_filters('https_ssl_verify', $r['sslverify']) |
|---|
| 99 | + ) |
|---|
| 100 | ); |
|---|
| 101 | |
|---|
| 102 | if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts |
|---|
| 103 | @@ -1153,28 +1171,31 @@ |
|---|
| 104 | $r['timeout'] = 1; |
|---|
| 105 | |
|---|
| 106 | $handle = curl_init(); |
|---|
| 107 | + |
|---|
| 108 | curl_setopt( $handle, CURLOPT_URL, $url); |
|---|
| 109 | + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); |
|---|
| 110 | + curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, apply_filters('https_ssl_verify', $r['sslverify']) ); |
|---|
| 111 | + curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, apply_filters('https_ssl_verify', $r['sslverify']) ); |
|---|
| 112 | + curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|---|
| 113 | + curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); |
|---|
| 114 | + curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); |
|---|
| 115 | + curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 116 | |
|---|
| 117 | - // The cURL extension requires that the option be set for the HEAD to |
|---|
| 118 | - // work properly. |
|---|
| 119 | - if ( 'HEAD' === $r['method'] ) { |
|---|
| 120 | - curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 121 | + switch ( $r['method'] ) { |
|---|
| 122 | + case 'HEAD': |
|---|
| 123 | + curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 124 | + break; |
|---|
| 125 | + case 'POST': |
|---|
| 126 | + curl_setopt( $handle, CURLOPT_POST, true ); |
|---|
| 127 | + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|---|
| 128 | + break; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | - if ( true === $r['blocking'] ) { |
|---|
| 132 | + if ( true === $r['blocking'] ) |
|---|
| 133 | curl_setopt( $handle, CURLOPT_HEADER, true ); |
|---|
| 134 | - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); |
|---|
| 135 | - } else { |
|---|
| 136 | + else |
|---|
| 137 | curl_setopt( $handle, CURLOPT_HEADER, false ); |
|---|
| 138 | - curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 139 | - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 ); |
|---|
| 140 | - } |
|---|
| 141 | |
|---|
| 142 | - curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|---|
| 143 | - curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); |
|---|
| 144 | - curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); |
|---|
| 145 | - curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 146 | - |
|---|
| 147 | // The option doesn't work with safe mode or when open_basedir is set. |
|---|
| 148 | if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) |
|---|
| 149 | curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); |
|---|