title: How to make fsockopen to ignore certificates when using tls
body: <p>In PHP7.0, when using fsockopen to connect to open a https connection (hosted in same
  host), using a host name like <code>tls://foo.localhost</code>, I am getting an error that
  looks like</p>
  
  <pre><code>fsockopen(): Peer certificate CN="bar" did not match expected CN="foo.localhost"
  </code></pre>
  
  <p>Connection is not opened.</p>
  
  <p>Same code worked in PHP 5.5 (that is less strict checking vertificates).  I do
  not really care about verifying certificates (this code runs in a unit test and
  integration suite, connecting only to localhost).  Tests need to be run against
  http and https, though.</p>
  
  <p>I know how to disable those checks when using <code>file_get_contents</code>.</p>
  
  <p>How can I disable the peer certificate verification when using fsockopen?</p>