title: PHP SoapClient: failed certificate verification
body: <p>I'm trying to send a soap request to some url. My SOAP options are:</p>
  
  <pre><code>array(
      'location' =&gt; 'https://some_url/',
      'features' =&gt; SOAP_SINGLE_ELEMENT_ARRAYS,
      'trace' =&gt; 1,
      'soap_version' =&gt; SOAP_1_2,
      'connection_timeout' =&gt; 60,
      'stream_context' =&gt; stream_context_create([
          'ssl' =&gt; [
              'verify_peer' =&gt; true,
              'verify_peer_name' =&gt; true,
              'allow_self_signed' =&gt; true,
              'cafile' =&gt; 'cacert.crt', // This file really exists, checked that
          ]
      ])
  );
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>SoapClient::__doRequest(): SSL operation failed with code 1. OpenSSL Error messages:
  error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01
  error:04067072:rsa routines:RSA_EAY_PUBLIC_DECRYPT:padding check failed
  error:0D0C5006:asn1 encoding routines:ASN1_item_verify:EVP lib
  error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
  </code></pre>
  
  <p>So I googled for "block type is not 01", but the results are pretty scarce. One might think that ca cert is wrong, but I fetched it with Chromium's Developer tools (Security tab) when I was on a page representing my url. Just to make sure that it's ok I put it in my browser and that page opens without any security warnings, showing me an XML response.
  Putting it in /usr/share/ca-certificates/ had no effect either.</p>
  
  <p>Certificate has pem encoding.</p>
  
  <p>verify_peer set to false is not an option of course.</p>
  
  <p>My php version is 5.5.17-2, the same behaviour is observed on PHP 7.0.21-1 though. OS is Ubuntu 16.04. OpenSSL 1.0.1 14 Mar 2012, the same effect on OpenSSL 1.0.2g-fips  1 Mar 2016.</p>
  
  <p>Any thoughts?</p>