Curl problems. Error 77 on localhost

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"

Forgot to include the output of the script, for clarification:

$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);
$cert = "my-cert.pem";
echo "cert loc $cert. File exists? ".(file_exists($cert) && is_readable($cert)?"yes":"no")."<br>";
curl_setopt($ch, CURLOPT_CAINFO, $cert);

$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"

My production server connects ok and outputs:

crt loc all-certs.pem. File exists? yes
curl errorno 0
err_str

But my test server fails and outputs:

cert loc all-certs.pem. File exists? yes
curl errorno 77
err_str error setting certificate verify locations: CAfile: all-certs.pem CApath: none