Make WordPress Core

Ticket #33978: 33978.patch

File 33978.patch, 2.9 KB (added by johnbillion, 10 years ago)
  • src/wp-includes/class-wp-http-curl.php

     
    133133                curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
    134134                curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false );
    135135                curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
    136                 curl_setopt( $handle, CURLOPT_CAINFO, $r['sslcertificates'] );
     136
     137                if ( $ssl_verify ) {
     138                        curl_setopt( $handle, CURLOPT_CAINFO, $r['sslcertificates'] );
     139                }
     140
    137141                curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );
    138142
    139143                /*
  • tests/phpunit/tests/http/base.php

     
    1414        // You can use your own version of data/WPHTTP-testcase-redirection-script.php here.
    1515        var $redirection_script = 'http://api.wordpress.org/core/tests/1.0/redirection.php';
    1616
     17        protected $http_request_args;
     18
    1719        function setUp() {
    1820
    1921                if ( is_callable( array('WP_Http', '_getTransport') ) ) {
     
    4143                parent::tearDown();
    4244        }
    4345
     46        function filter_http_request_args( array $args ) {
     47                $this->http_request_args = $args;
     48                return $args;
     49        }
     50
    4451        function test_redirect_on_301() {
    4552                // 5 : 5 & 301
    4653                $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) );
     
    283290        }
    284291
    285292        /**
     293         * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated
     294         *
     295         * @ticket 33978
     296         */
     297        function test_https_url_without_ssl_verification() {
     298                $url = 'https://wordpress.org/';
     299                $args = array(
     300                        'sslverify' => false,
     301                );
     302
     303                add_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) );
     304
     305                $res = wp_remote_head( $url, $args );
     306
     307                remove_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) );
     308
     309                $this->assertNotEmpty( $this->http_request_args['sslcertificates'] );
     310                $this->assertNotWPError( $res );
     311        }
     312
     313        /**
    286314         * Test HTTP Redirects with multiple Location headers specified
    287315         *
    288316         * @ticket 16890
  • tests/phpunit/includes/testcase.php

     
    301301                $this->assertInstanceOf( 'WP_Error', $actual, $message );
    302302        }
    303303
     304        function assertNotWPError( $actual, $message = '' ) {
     305                if ( is_wp_error( $actual ) && '' === $message ) {
     306                        $message = $actual->get_error_message();
     307                }
     308                $this->assertNotInstanceOf( 'WP_Error', $actual, $message );
     309        }
     310
    304311        function assertEqualFields( $object, $fields ) {
    305312                foreach( $fields as $field_name => $field_value ) {
    306313                        if ( $object->$field_name != $field_value ) {