I'm attempting to add a custom cer
-certificate to my PHP cURL request, but I keep getting this error:
error setting certificate verify locations:
CAfile: /path/to/my/cert.cer
CApath: none
All I've found about this error is that:
The path is relative.
As you can see, I've supplied an absolute path.The path is erroneous.
I've tried tovar_dump(file_exists($certLocation));
, which gives metrue
, so this is not the case.The permissions on the file are incorrect.
I've set the permissions to777
for debugging purposes. Error remains.The path to the file doesn't have
+x
-permissions somewhere in the chain.
I've set this as well, ensuring that the entire path from root has+x
-permissions, and still no luck.
I'm at a loss here, having tried everything I can find, and fact is, I don't even understand what the error actually means. What is a verify location
? All I can understand is that there's an error with loading the file.
Any light shed on this is greatly appreciated. See code example below.
Thanks.
Code I use:
<?php
$oCurl = curl_init($this->baseUrl);
curl_setopt($oCurl, CURLOPT_FAILONERROR, 1);
curl_setopt($oCurl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($oCurl, CURLOPT_POST, 1);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($oCurl, CURLOPT_CAINFO, "/tmp/cert.cer");
Error:
error setting certificate verify locations:
CAfile: /tmp/cert.cer
CApath: none