title: Allow self-signed certificates for HTTPS wrapper
body: <p>Basically i have this:</p>
  
  <pre><code>function request($url) {
      return file_get_contents($url, false, stream_context_create(array(
          "ssl" =&gt; array(
              "verify_peer" =&gt; true,
              "allow_self_signed" =&gt; false,
          )
      )));
  }
  
  request("https://[A]");
  request("https://[B]");
  </code></pre>
  
  <p>Where [A] is some URL on a server with a "real" certificate and [B] is something on one with only a self-signed certificate.</p>
  
  <p>With [A] it works fine, with [B] i get this:</p>
  
  <pre><code>file_get_contents(): Failed to enable crypto
  </code></pre>
  
  <p>Which is a rather unfortunate error message that should have been something like "server certificate verification failed", but fine...</p>
  
  <p>Now i thought: "ok, [B] is my test system - i don't care for the certificate" and changed the context into this:</p>
  
  <pre><code>"verify_peer" =&gt; false,
  "allow_self_signed" =&gt; true,
  </code></pre>
  
  <p>It <a href="http://php.net/manual/en/context.ssl.php" rel="noreferrer">should</a> now accept any server certificate, even my self signed one. But it's still the same behavior - [A] works, [B] doesn't. Why?</p>
  
  <hr>
  
  <p>Btw: I know that it works well with the curl extension, but i want to beat this without it.</p>