I have a curl script to connect to an online payment gateway securely.
When I run this on my localhost (windows machine) curl reports an error 77 “setting certificate verify locations: CAfile: my-cert.pem CApath: none”
Running the same code on my online server runs fine with no error.
Error 77 seems to be some kind of file read error, but I’ve created .pem root certificates from thawte. In both cases it’s in the same directory as the running script. I have curl enabled in my php config.
Any ideas why it would give this error?
the code:
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, "https://testserver.com/gateway" );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, array("dog"=>"bark","cat"=>"meow") );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array('Expect: ') );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CAINFO, "my-cert.pem");
$response = curl_exec ($ch);
$errno = curl_errno ($ch);
$err_str = curl_error ($ch);
$curl_getinfo = curl_getinfo( $ch );
curl_close ($ch);
echo "curl errorno $errno<br>err_str $err_str"