title: Curl Error: unable to set private key file: 'test.pem' type PEM
body: <p>My Pem file is in this format. </p>
  
  <pre><code>Bag Attributes
  localKeyID:
  friendlyName: test
  subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
  issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
  -----BEGIN CERTIFICATE-----
  
  -----END CERTIFICATE-----
  
  Bag Attributes
  localKeyID:
  friendlyName: test
  subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
  issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
  -----BEGIN CERTIFICATE-----
  
  -----END CERTIFICATE-----
  
  Bag Attributes
  localKeyID:
  friendlyName: test
  subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
  issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
  -----BEGIN RSA PRIVATE KEY-----
  Proc-Type: 4,ENCRYPTED
  DEK-Info: DES-EDE3-CBC,B9E036426B7AEDA6
  -----END RSA PRIVATE KEY-----
  </code></pre>
  
  <p>I'm using this code of PHP. I'm getting this error. </p>
  
  <blockquote>
    <p>Curl Error: unable to set private key file: 'test.pem' type PEM</p>
  </blockquote>
  
  <p>Code.</p>
  
  <pre><code>   $json_data  // it's a json array.
  
      $url = "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
  
      // $pemFile = tmpfile();
      // fwrite($pemFile, "test.pem");   //the path for the pem file
      // $tempPemPath = stream_get_meta_data($pemFile);
      // $tempPemPath = $tempPemPath['uri'];
  
      curl_setopt($ch, CURLOPT_SSLCERT, "test.pem"); 
      curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM");
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/javascript'));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
      curl_setopt($ch, CURLOPT_POST, True);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
      curl_setopt($ch, CURLOPT_VERBOSE, true);
  
      $result = curl_exec($ch);
  
      if(!$result)
      {
          echo "Curl Error: " . curl_error($ch);
      }
      else
      {
          echo "Success: ". $result;
      }
  
      $info = curl_getinfo($ch);
  
      curl_close($ch); // close cURL handler
  
      if (empty($info['http_code'])) {
              die("No HTTP code was returned"); 
      } else {
          // load the HTTP codes
          $http_codes = parse_ini_file("path/to/the/ini/file/I/pasted/above");
  
          // echo results
          echo "The server responded: &lt;br /&gt;";
          echo $info['http_code'] . " " . $http_codes[$info['http_code']];
      }
  </code></pre>
  
  <p>I check online for certificate decoder : 
  <a href="https://www.sslshopper.com/certificate-decoder.html" rel="nofollow">https://www.sslshopper.com/certificate-decoder.html</a>
  and certificate is valid on this site. </p>
  
  <p>So what is the problem here i can't figure it out. 
  I tried with ssl command also.</p>