X-Git-Url: http://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=78c2ac7a38d05b6ffa9681d7fdda5dc355be02e7;hb=370f4c4618fa7e35764691ea03c42912774989be;hp=cf36d2e97a629de59eb8d06ac624ac807aebd5c9;hpb=5b0939fa1956f5bc2c936510c64395d9c74ac739;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index cf36d2e97a..78c2ac7a38 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -46,9 +46,9 @@ class Http { * Otherwise it will use $wgHTTPProxy (if set) * Otherwise it will use the environment variable "http_proxy" (if set) * - noProxy Don't use any proxy at all. Takes precedence over proxy value(s). - * - sslVerifyHost (curl only) Verify hostname against certificate - * - sslVerifyCert (curl only) Verify SSL certificate - * - caInfo (curl only) Provide CA information + * - sslVerifyHost Verify hostname against certificate + * - sslVerifyCert Verify SSL certificate + * - caInfo Provide CA information * - maxRedirects Maximum number of redirects to follow (defaults to 5) * - followRedirects Whether to follow redirects (defaults to false). * Note: this should only be used when the target URL is trusted, @@ -66,7 +66,7 @@ class Http { if ( !isset( $options['timeout'] ) ) { $options['timeout'] = 'default'; } - if( !isset( $options['connectTimeout'] ) ) { + if ( !isset( $options['connectTimeout'] ) ) { $options['connectTimeout'] = 'default'; } @@ -885,7 +885,23 @@ class PhpHttpRequest extends MWHttpRequest { $options['timeout'] = $this->timeout; - $context = stream_context_create( array( 'http' => $options ) ); + if ( $this->sslVerifyHost ) { + $options['CN_match'] = $this->parsedUrl['host']; + } + if ( $this->sslVerifyCert ) { + $options['verify_peer'] = true; + } + + if ( is_dir( $this->caInfo ) ) { + $options['capath'] = $this->caInfo; + } elseif ( is_file( $this->caInfo ) ) { + $options['cafile'] = $this->caInfo; + } elseif ( $this->caInfo ) { + throw new MWException( "Invalid CA info passed: {$this->caInfo}" ); + } + + $scheme = $this->parsedUrl['scheme']; + $context = stream_context_create( array( "$scheme" => $options ) ); $this->headerList = array(); $reqCount = 0;