title: How to force a certain TLS version in a PHP stream context for the ssl:// transport?
body: <p>How can I force TLSv1.0 in a PHP stream context when trying to access an <code>https</code> URL?</p>
  
  <p>I’m looking for something along the lines of this:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>$context = stream_context_create(
    array(
      'ssl' =&gt; array(
        'protocol_version' =&gt; 'tls1',
      ),
    ));
  file_get_contents('https://example.com/test', false, $context);
  </code></pre>
  
  <h3>Background</h3>
  
  <p>Actually I’m facing <a href="https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/965371" rel="noreferrer">an issue in Ubuntu 12.04</a> when working with PHP’s <a href="http://php.net/manual/de/class.soapclient.php" rel="noreferrer"><code>SoapClient</code></a>. Unfortunately, the server I’m trying to connect to does only support SSLv3.0/TLSv1.0 and fails on the default TLSv1.1 negotiation. Therefore I’d like to explicitly set the protocol of the <code>ssl://</code> transport to TLSv1.0.</p>