PHP Developers Network

PHP - Using cURL to access HTTPS (SSL) protected sites
Page 1 of 1

Author:  Ren101 [ Tue May 01, 2012 3:41 am ]
Post subject:  PHP - Using cURL to access HTTPS (SSL) protected sites

The following code returns Exit code 58.

From cURL documentation:
problem with the local client certificate.

Syntax: [ Download ] [ Hide ]
    // create a new CURL resource
    $ch = curl_init();
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSLCERT, getcwd() . $CERT);
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD,"XXXXX");
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content Type: text/xml',
        'User-Agent: XXXXX',
        'User-Name: XXXXX'
    $RESPONSE = curl_exec($ch);  
    // close CURL resource, and free up system resources

Is there something I'm missing?

Author:  pickle [ Tue May 01, 2012 12:07 pm ]
Post subject:  Re: PHP - Using cURL to access HTTPS (SSL) protected sites

My guess is cURL is having difficulty verifying the certificate. Try commenting out the two verification steps to see if that works. Note that this is just a test to see where the problem is - you should always verify.

If that doesn't change anything, then it's probably the next 2 lines. Make sure you're specifying the correct path to your .PEM file.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group