title: PHP fopen with proxy and https
body: <p>I'm using <code>fopen</code> of PHP to connect to other sites, but it doesn't work. The requesting server use a proxy and the target server is on https. So here are the context configuration :</p>
  
  <pre><code>["http"]=&gt; array(5) { 
     ["method"]=&gt; string(3) "GET" 
     ["ignore_errors"]=&gt; int(1) 
     ["header"]=&gt; string(197) "Content-type: application/x-www-form-urlencoded Authorization: Basic ...." 
     ["proxy"]=&gt; string(23)     "tcp://192.168.83.6:8080" 
     ["request_fulluri"]=&gt; bool(true) 
  }
  </code></pre>
  
  <p>Gives a response : <code>Bad Request. Your browser sent a request that this server could not understand.</code></p>
  
  <p>So I searched a bit and following some guides, this is my new configuration using ssl proxy protocol:</p>
  
  <pre><code>["http"]=&gt; array(5) { 
     ["method"]=&gt; string(3) "GET" 
     ["ignore_errors"]=&gt; int(1) 
     ["header"]=&gt; string(197) "Content-type: application/x-www-form-urlencoded Authorization: Basic ...." 
     ["proxy"]=&gt; string(23)     "ssl://192.168.83.6:8080" 
     ["request_fulluri"]=&gt; bool(true) 
  },
  
   //http://www.php.net/manual/en/context.ssl.php
  'ssl' =&gt; array(
       'verify_peer' =&gt; true,
       'allow_self_signed' =&gt; true,
       'cafile'        =&gt; '/etc/ssl/certs/ca-certificates.crt',
       'verify_depth'  =&gt; 5,
       'CN_match' =&gt; 'somesite.com',
       'disable_compression' =&gt; true,
       'SNI_enabled'         =&gt; true,
     )
  </code></pre>
  
  <p>Error : <code>Warning: fopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in ...php on line 237 Warning: fopen(): Failed to enable crypto in ...</code></p>
  
  <p>OpenSSL support enabled</p>
  
  <p>OpenSSL Library Version OpenSSL 0.9.8o 01 Jun 2010</p>
  
  <p>OpenSSL Header Version  OpenSSL 0.9.8o 01 Jun 2010</p>
  
  <p>Please help!</p>