title: How to get SSL connection with PHP SOAP extension?
body: <p>When trying to connect to an SSL endpoint with PHP SOAP extension on Windows I am getting the SoapFault "Could not connect to host". Client certificate is not a requirement of the service.</p>
  
  <pre><code>$sslOptions = array(
      'ssl' =&gt; array(
          'cafile' =&gt; "c:/inetpub/wwwroot/eServices/Server_DSA_Public_Certificate.pem",
          'allow_self_signed' =&gt; true,
          'verify_peer' =&gt; false,
       ),
  );      
  $sslContext = stream_context_create($sslOptions);
  
  $clientArguments = array(
      'stream_context' =&gt; $sslContext,
      'trace' =&gt; true,
      'exceptions' =&gt; true,           
      'encoding' =&gt; 'UTF-8',
      'soap_version' =&gt; SOAP_1_1,
  );
  
  $oClient = new WSSoapClient("c:/inetpub/wwwroot/eServices/svc.wsdl", $clientArguments);  
  // WSSoapClient extends SoapClient to add a WS-Security UsernameToken header    
  
  $oClient-&gt;__setUsernameToken("myusername", "mypassword");   
  return $oClient-&gt;__soapCall($operation, $request);
  </code></pre>
  
  <p>I converted to .pem format a self-signed server certificate (.cer) that I was given and am passing that in as 'cacert'.</p>
  
  <p>Am able to access the service perfectly using soapUI with the same wsdl.</p>
  
  <p>Question: Do I need to put the server certificate into some trust store?  I did already use Internet Explorer to add it into 'Trusted Root Certification Authorities'.</p>
  
  <p>Question: By passing in 'cacert', is it enough for PHP to know it can trust the server?</p>
  
  <p>Any help or suggestions would be much appreciated.</p>