By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

file_get_contents + https + proxy + authentificationS

P: n/a
Hi,

I am searching how to solve a problem and I dont find it :(
I want to access a page from a script behind a proxy :

(my script) <-(a proxy with authentification) <-(https serveur
with authentification)

-----------------------------------------------------------------

I get this error :
PHP Warning: file_get_contents(): SSL: fatal protocol error in F:\Data
\Scripts-html\php-test-file_get_contents\HTTP_Proxy_auth.php on line
33

Warning: file_get_contents(): SSL: fatal protocol error in F:\Data
\Scripts-html\php-test-file_get_contents\HTTP_Proxy_auth.php on line
33
PHP Warning: file_get_contents(https://logs.ovh.net/xxx-xxxx.xxx/
logs-12-2007/): failed to open stream: Cannot connect to HTTPS server
through proxy
in F:\Data\Scripts-html\php-test-file_get_contents\HTTP_Proxy_auth.php
on line 33

Warning: file_get_contents(https://logs.ovh.net/xxx-xxxx.xxx/
logs-12-2007/): failed to open stream: Cannot connect to HTTPS server
through proxy in F:
\Data\Scripts-html\php-test-file_get_contents\HTTP_Proxy_auth.php on
line 33

(Error reporting is set to E_ALL)

-----------------------------------------------------------------

Here is my script :
<?php

error_reporting(E_ALL);

$authPage = base64_encode("xxxxxxx:xxxxxxxxx");
$authProx = base64_encode("xxxxxxxxxx:xxxxxxxxx");

$url = 'https://logs.ovh.net/xxx-xxxx.xxx/logs-12-2007/';

$header = "Accept: text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n"
."Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n"
."Accept-Encoding: gzip,deflate\r\n"
."Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
."Keep-Alive: 300\r\n"
."Proxy-Connection: keep-alive\r\n"
."Proxy-Authorization: Basic {$authProx}\r\n"
."Authorization: Basic {$authPage}";

$opts = array (
'proxy' ='tcp://xxxxx.xxx.xx.xxxx.fr:8080',
'request_fulluri' =true,
'method'=>'GET',
'header'=>$header
);

var_dump($opts);

$ctx = stream_context_create(array('http'=>$opts,'https'= >$opts));

echo file_get_contents($url,false,$ctx);

?>
-----------------------------------------------------------------

If someone see where is the problem, it would be cool ;)
thx
Dec 21 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.