SSL certificate problem, verify that the CA cert is OK

Indien bij een cURL request een URL wordt aangeroepen met een Self Signed Certificaat onstaat deze foutmelding:

Request_Exception [ 0 ]: Error fetching remote http://localhost/test [ status 0 ] SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed


Oplossing
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

CURLOPT_SSL_VERIFYHOST

to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided. In production environments the value of this option should be kept at 2 (default value).

CURLOPT_SSL_VERIFYPEER

FALSE to stop cURL from verifying the peer's certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option.

Kohana 3.2
Request::factory(..)->client()->options(array(
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0
));

Optioneel

Om er toch zeker van te zijn dat je communiceert met de juiste server heb je een kopie van het certificaat in PEM formaat nodig:

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($ch, CURLOPT_CAINFO, "het-volledige-path/cacert.pem");

CURLOPT_SSL_VERIFYPEER

The name of a file holding one or more certificates to verify the peer with. This only makes sense when used in combination with CURLOPT_SSL_VERIFYPEER.

Indien het certificaat is aangemaakt door een Certificate Authority kan je deze ook vergelijken met Mozilla's Certificate Authority Bundle:

cURL - Extract CA Certs from Mozilla


Meer informatie: PHP: curl_setopt - Manual | Requests | Kohana User Guide