title: Php SoapClient stream_context option
body: <p>I want to use a third party's web service. To use the web service I need to connect with HTTPS. My problem is that for the development process I have a test api with an invalid certificate. I would like to set SoapClient no to verify the server's certificate. Here is the way I tried:</p>
  
  <pre><code>$opts = array(
      'ssl'   =&gt; array(
              'verify_peer'          =&gt; false
          ),
      'https' =&gt; array(
              'curl_verify_ssl_peer'  =&gt; false,
              'curl_verify_ssl_host'  =&gt; false
       )
  );
  $streamContext = stream_context_create($opts);
  $client = new SoapClient("https://urlToSoapWs",
    array(
        'login'             =&gt; 'user',
        'password'          =&gt; 'pwd',
        'authentication'    =&gt; SOAP_AUTHENTICATION_BASIC,
        'local_cert'        =&gt; file_get_contents('C:/somelocation/1.pem'),
        'passphrase'        =&gt; 'passphrase',
        'stream_context'    =&gt; $streamContext
    ));
  </code></pre>
  
  <p>I also tried with CURL and worked! But I want to use SoapClient. You can find the code with CURL below:</p>
  
  <pre><code>// create a new cURL resource
  $ch = curl_init("https://urlToSoapWs");
  
  // setting the request type to POST: 
  curl_setopt($ch, CURLOPT_POST, 1);
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); 
  // setting the authorization method to BASIC: 
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
  // supplying your credentials: 
  curl_setopt($ch, CURLOPT_USERPWD, "user:pwd");
  
  $body = "&lt;SOAP-ENV:Envelope&gt;somexmlhere&lt;/SOAP-ENV:Envelope&gt;";
  // filling the request body with your SOAP message: 
  curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  
  // configuring cURL not to verify the server certificate: 
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_SSLCERT, "pathToTheCertificatePemFile");
  curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "pwd");
  //curl_setopt($ch, CURLOPT_SSLCERTTYPE, "PEM");
  
  curl_setopt($ch, CURLOPT_SSLKEY, "pathTotheKeyFile");
  curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "pwd");
  
  // telling cURL to return the HTTP response body as operation result 
  // value when calling curl_exec: 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  // calling cURL and saving the SOAP response message in a variable which 
  // contains a string like "&lt;SOAP-ENV:Envelope ...&gt;...&lt;/SOAP-ENV:Envelope&gt;": 
  
  
  $result = curl_exec($ch);
  // closing cURL: 
  curl_close($ch);
  </code></pre>
  
  <p>If you have found the bug in the code that I provided using the SoapClient please post it.
  Thanks.</p>