Ticket #8702: 8702.3.diff
| File 8702.3.diff, 6.5 KB (added by , 17 years ago) |
|---|
-
wp-includes/cron.php
201 201 202 202 update_option( 'doing_cron', $local_time + 30 ); 203 203 204 wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false ));204 wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))); 205 205 } 206 206 207 207 /** -
wp-includes/http.php
237 237 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 238 238 $working_transport['streams'] = new WP_Http_Streams(); 239 239 $blocking_transport[] = &$working_transport['streams']; 240 } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) {240 } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { 241 241 $working_transport['fopen'] = new WP_Http_Fopen(); 242 242 $blocking_transport[] = &$working_transport['fopen']; 243 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {243 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { 244 244 $working_transport['fsockopen'] = new WP_Http_Fsockopen(); 245 245 $blocking_transport[] = &$working_transport['fsockopen']; 246 246 } … … 282 282 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { 283 283 $working_transport['exthttp'] = new WP_Http_ExtHttp(); 284 284 $blocking_transport[] = &$working_transport['exthttp']; 285 } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { 286 $working_transport['curl'] = new WP_Http_Curl(); 287 $blocking_transport[] = &$working_transport['curl']; 285 288 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 286 289 $working_transport['streams'] = new WP_Http_Streams(); 287 290 $blocking_transport[] = &$working_transport['streams']; 288 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {291 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { 289 292 $working_transport['fsockopen'] = new WP_Http_Fsockopen(); 290 293 $blocking_transport[] = &$working_transport['fsockopen']; 291 294 } 292 295 293 foreach ( array(' streams', 'fsockopen', 'exthttp') as $transport ) {296 foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) { 294 297 if ( isset($working_transport[$transport]) ) 295 298 $nonblocking_transport[] = &$working_transport[$transport]; 296 299 } … … 358 361 'timeout' => apply_filters( 'http_request_timeout', 5), 359 362 'redirection' => apply_filters( 'http_request_redirection_count', 5), 360 363 'httpversion' => apply_filters( 'http_request_version', '1.0'), 361 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ),364 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 362 365 'blocking' => true, 363 366 'headers' => array(), 364 367 'body' => null, 365 368 'compress' => false, 366 'decompress' => true 369 'decompress' => true, 370 'sslverify' => true 367 371 ); 368 372 369 373 $r = wp_parse_args( $args, $defaults ); 370 374 $r = apply_filters( 'http_request_args', $r, $url ); 371 375 376 $arrURL = parse_url($url); 377 378 // Determine if this is a https call and pass that on to the transport functions 379 // so that we can blacklist the transports that do not support ssl verification 380 if ( $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl' ) 381 $r['ssl'] = true; 382 else 383 $r['ssl'] = false; 384 372 385 if ( is_null( $r['headers'] ) ) 373 386 $r['headers'] = array(); 374 387 … … 927 940 'max_redirects' => $r['redirection'], 928 941 'protocol_version' => (float) $r['httpversion'], 929 942 'header' => $strHeaders, 930 'timeout' => $r['timeout'] 943 'timeout' => $r['timeout'], 944 'verify_peer' => apply_filters('https_ssl_verify', $r['sslverify']) 931 945 ) 932 946 ); 933 947 … … 1060 1074 'redirect' => $r['redirection'], 1061 1075 'useragent' => $r['user-agent'], 1062 1076 'headers' => $r['headers'], 1077 'ssl' => array( 1078 'verifypeer' => apply_filters('https_ssl_verify', $r['sslverify']), 1079 'verifyhost' => apply_filters('https_ssl_verify', $r['sslverify']) 1080 ) 1063 1081 ); 1064 1082 1065 1083 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts … … 1153 1171 $r['timeout'] = 1; 1154 1172 1155 1173 $handle = curl_init(); 1174 1156 1175 curl_setopt( $handle, CURLOPT_URL, $url); 1176 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); 1177 curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, apply_filters('https_ssl_verify', $r['sslverify']) ); 1178 curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, apply_filters('https_ssl_verify', $r['sslverify']) ); 1179 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); 1180 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); 1181 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); 1182 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1157 1183 1158 // The cURL extension requires that the option be set for the HEAD to 1159 // work properly. 1160 if ( 'HEAD' === $r['method'] ) { 1161 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1184 switch ( $r['method'] ) { 1185 case 'HEAD': 1186 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1187 break; 1188 case 'POST': 1189 curl_setopt( $handle, CURLOPT_POST, true ); 1190 curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); 1191 break; 1162 1192 } 1163 1193 1164 if ( true === $r['blocking'] ) {1194 if ( true === $r['blocking'] ) 1165 1195 curl_setopt( $handle, CURLOPT_HEADER, true ); 1166 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); 1167 } else { 1196 else 1168 1197 curl_setopt( $handle, CURLOPT_HEADER, false ); 1169 curl_setopt( $handle, CURLOPT_NOBODY, true );1170 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 );1171 }1172 1198 1173 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );1174 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );1175 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );1176 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );1177 1178 1199 // The option doesn't work with safe mode or when open_basedir is set. 1179 1200 if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 1180 1201 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );