title: CURLOPT_SSL_VERIFYPEER option gives certificate error
body: <p>Hi I have following code and corresponding logs. Please let me know if anyone can figure out certificate problem.</p>
  
  <pre><code>/////////////////////////////////////////////php curl code//////////////////////////////////////////
      curl_setopt_array($handle, array(
      CURLOPT_SSL_VERIFYPEER =&gt; true,
      CURLOPT_SSL_VERIFYHOST =&gt; 2,
      CURLOPT_VERBOSE =&gt; true,
      CURLOPT_HEADER =&gt; true,
      CURLOPT_CAINFO =&gt; 'C:\wamp\www\server.pem',
      CURLOPT_HTTPHEADER =&gt; $headers,
      CURLOPT_POSTFIELDS =&gt; $credentials,
      CURLOPT_SSLCERT =&gt; 'C:\wamp\bin\apache\Apache2.4.4\conf\ssl.cert\server.crt',
      CURLOPT_SSLKEY =&gt; 'C:\wamp\bin\apache\Apache2.4.4\conf\ssl.key\server.key',
      CURLOPT_SSLCERTPASSWD =&gt; "mypassphrase",
      CURLOPT_HTTPAUTH =&gt; CURLOPT_HTTPAUTH ,
      CURLOPT_RETURNTRANSFER =&gt; false,
      CURLOPT_POST =&gt; true,);
  
  $response=curl_exec($handle);
      if (false ===$response ) {
      echo "Error while loading page: ". curl_error($handle). "\n";
      }
      else
      {
          echo "success while loading page: ".curl_error($handle)."\n";
          echo $response;
      }
      $status_code=curl_getinfo($handle, CURLINFO_HTTP_CODE);
  //     echo "status code --&gt; $status_code" . "\n";
      $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
              echo "header_size--&gt;$header_size ","\n";
      $header = substr($response, 0, $header_size);
              echo "header ---&gt;$header ","\n";
      $body = substr($response, $header_size);
              echo "body---: $body ","\n";
      curl_close($handle);        
  </code></pre>
  
  <p>/////////////////////////////////////////////////////////////////////////////////////////////////</p>
  
  <p>///////////////Apache_error_log///////////////////////</p>
  
  <pre><code>* Adding handle: conn: 0x21a1f58
  * Adding handle: send: 0
  * Adding handle: recv: 0
  * Curl_addHandleToPipeline: length: 1
  * - Conn 0 (0x21a1f58) send_pipe: 1, recv_pipe: 0
  * About to connect() to my.site.com port 8443 (#0)
  *   Trying my.site.com...
  * Connected to my.site.com port 8443 (#0)
  * successfully set certificate verify locations:
  *   CAfile: C:\wamp\www\server.pem
    CApath: none
  * SSL connection using DHE-RSA-AES256-SHA
  * Server certificate:
  *    subject: CN=my.site.com
  *    start date: 2013-07-09 07:57:53 GMT
  *    expire date: 2013-07-09 07:57:53 GMT
  *    common name: my.site.com (matched)
  *    issuer: CN=my.site.com
  *    SSL certificate verify ok.
  &gt; POST /v2/dip/auth/login HTTP/1.1
  
  Host: my.site.com:8443
  
  Accept: */*
  
  contentType:application/json
  
  MY-API-Key:@#@$@#$SDsdfsdfdsw1212312323123
  
  Content-Length: -1
  
  Content-Type: application/x-www-form-urlencoded
  
  Expect: 100-continue
  
  
  
  &lt; HTTP/1.1 400 Bad Request
  
  * Server Apache-Coyote/1.1 is not blacklisted
  &lt; Server: Apache-Coyote/1.1
  
  &lt; Transfer-Encoding: chunked
  
  &lt; Date: Tue, 24 Dec 2013 09:37:32 GMT
  
  &lt; Connection: close
  
  &lt; 
  
  * Closing connection 0
  [Mon Dec 23 14:38:08.561536 2013] [mpm_winnt:notice] [pid 328:tid 560] AH00430: Parent: Child process 8080 exited successfully.
  [Mon Dec 23 14:38:11.019782 2013] [mpm_winnt:notice] [pid 9308:tid 560] AH00455: Apache/2.4.4 (Win32) OpenSSL/1.0.1e PHP/5.4.16 configured -- resuming normal operations
  ////////////////////////////////////////////////////////////////////////////////////////////
  
  //////////////////////////////////////access.log//////////////////////////////////////
  127.0.0.1 - - [23/Dec/2013:14:39:41 +0530] "GET /curltest.php HTTP/1.1" 200 359
  
  ///////////////////////////////////////sslerror.log/////////////////////////////////////
  [Mon Dec 23 14:38:11.627843 2013] [ssl:warn] [pid 9972:tid 456] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
  [Mon Dec 23 14:38:11.627843 2013] [ssl:warn] [pid 9972:tid 456] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
  [Mon Dec 23 14:38:11.739854 2013] [ssl:warn] [pid 9972:tid 456] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
  [Mon Dec 23 14:38:11.739854 2013] [ssl:warn] [pid 9972:tid 456] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
  </code></pre>
  
  <p>If I set CURLOPT_SSL_VERIFYPEER to <strong>true</strong> then it gives me SSL certificate problem: self signed certificate </p>
  
  <p>and if I set it to <strong>false</strong> then it gives <strong>"HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Date: Tue, 24 Dec 2013 09:56:33 GMT Connection: close "</strong></p>
  
  <p>Any idea would help</p>