title: cURL with SSL certificates fails: error 58 unable to set private key file
body: <p>I'm trying to connect to a remote host using cURL. The connection requires the use of a certificate and a private key which is password protected. So far I'm unsuccessful with this code below:</p>
  
  <pre><code>&lt;?php
      $wsdl       = 'https://domain.com/?wsdl';
      $certFile   = getcwd() . '/auth/cert.pem';
      $keyFile    = getcwd() . '/auth/key.pem';
      $password   = 'pwd';
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,           $wsdl);
      curl_setopt($ch, CURLOPT_SSLCERT,       $certFile);
      curl_setopt($ch, CURLOPT_SSLKEYPASSWD,  $password);
      curl_setopt($ch, CURLOPT_SSLKEY,        $keyFile);
      #curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
      #curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      #curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
      $output = curl_exec($ch);
  
      var_dump(curl_errno($ch));
      var_dump(curl_error($ch));
  </code></pre>
  
  <p>The result I keep getting is error <code>58</code>: <code>unable to set private key file: '/home/.../domains/.../public_html/auth/key.pem' type PEM</code>.</p>
  
  <p>Things I've tried so far:</p>
  
  <ul>
  <li>Check if the key-file is readable as suggested here: <a href="https://stackoverflow.com/questions/6124289/unable-to-use-libcurl-to-access-a-site-requiring-client-authentication">Unable to use libcurl to access a site requiring client authentication</a>. Trying to pass the file through <code>openssl_private_key()</code> gives me a resource, and not a boolean. So this seems good.</li>
  <li>Switch the order of the content in the key.pem file as suggested here: <a href="https://stackoverflow.com/questions/6124289/unable-to-use-libcurl-to-access-a-site-requiring-client-authentication">Unable to use libcurl to access a site requiring client authentication</a>. No luck so far.</li>
  <li>Played around with some other options like <code>SLL_VERIFY_PEER</code>, <code>SSL_VERIFY_HOST</code>, <code>SSL_CERTTYPE</code> and other options which seemed trivial regarding the official PHP-docs. No luck so far.</li>
  </ul>
  
  <p>I'm pretty sure the problem lies somehwere in my configuration, but I'm not sure where to look. </p>