title: How to set 'verify_peer_name=false' SSL context option via php.ini in PHP 5.6
body: <p>The case: I would like to open SSL connection to <code>localhost</code> while SSL certificate was issues for FQDN.</p>
  
  <p>The problem: Without special handling in line <code>(*)</code> the program below fails with the following message:</p>
  
  <p><code>PHP Warning:  stream_socket_enable_crypto(): Peer certificate CN='myhost.com' did not match expected CN='localhost' in test.php</code></p>
  
  <p>The test PHP program:</p>
  
  <pre><code>$fp = stream_socket_client("tcp://localhost:993", $errno, $errstr, 30);
  
  // (*) if commented, the program fails
  //stream_context_set_option($fp, 'ssl', 'verify_peer_name', false); 
  
  if (!$fp) {
          die("Unable to connect: $errstr ($errno)");
  }
  if (!stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
          die("Failed to start SSL");
  }
  fwrite($fp, "USER god\r\n");
  fwrite($fp, "PASS secret\r\n");
  while ($motd = fgets($fp)) {
          echo $motd;
  }
  fclose($fp);
  </code></pre>
  
  <p>As I have a lot of legacy code, I would love to have a solution by only applying changes to <code>php.ini</code> (or CLI), but unfortunately neither of below works:</p>
  
  <p><code>php -d verify_peer_name=false test.php</code></p>
  
  <p><code>php -d ssl.verify_peer_name=false test.php</code></p>
  
  <p>Ideas?</p>
  
  <p>References:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/26151993/267197">SSL operation failed with code 1</a></li>
  <li><a href="https://stackoverflow.com/a/13436527/267197">How do I verify a TLS SMTP certificate is valid?</a></li>
  <li><a href="http://www.docnet.nu/tech-portal/2014/06/26/ssl-and-php-streams-part-1-you-are-doing-it-wrongtm/C0" rel="nofollow noreferrer">SSL and PHP streams</a></li>
  <li><a href="http://lists.horde.org/archives/horde/Week-of-Mon-20140609/051807.html" rel="nofollow noreferrer">SSL solution for PHP 5.6</a></li>
  <li><a href="http://php.net/manual/en/migration56.openssl.php#migration56.openssl.peer-verification" rel="nofollow noreferrer">OpenSSL changes in PHP 5.6.x</a></li>
  <li><a href="http://php.net/manual/en/context.ssl.php" rel="nofollow noreferrer">SSL context options</a></li>
  </ul>