I use WAMP on a local development environment and am trying to charge a credit card but get the error message:
cURL error 60: SSL certificate problem:
when I run 'var_dump(php_ini_loaded_file());'
I get this output on my page
'C:\Development\bin\apache\apache2.4.33\bin\php.ini' (length=50)'
and to get php to load my cert file I had to edit the php.ini in this path 'C:\Development\bin\apache\apache2.4.33\bin\php.ini'
and add openssl.cafile="C:/Development/bin/php/php7.2.4/extras/ssl/cacert.pem"
where I had downloaded and place my cert file from https://curl.haxx.se/docs/caextract.html
am on windows 10, using drupal 8, wamp and php7.2.4
if you use WAMP you should also add the certificate line in php.ini for Apache (besides the default php.ini file):
[curl]
curl.cainfo = C:\your_location\cacert.pem
works for php5.3+
I just experienced this same problem with the Laravel 4 php framework which uses the guzzlehttp/guzzle
composer package. For some reason, the SSL certificate for mailgun stopped validating suddenly and I got that same "error 60" message.
If, like me, you are on a shared hosting without access to php.ini
, the other solutions are not possible. In any case, Guzzle has this client initializing code that would most likely nullify the php.ini
effects:
// vendor/guzzlehttp/guzzle/src/Client.php
$settings = [
'allow_redirects' => true,
'exceptions' => true,
'decode_content' => true,
'verify' => __DIR__ . '/cacert.pem'
];
Here Guzzle forces usage of its own internal cacert.pem file, which is probably now out of date, instead of using the one provided by cURL's environment. Changing this line (on Linux at least) configures Guzzle to use cURL's default SSL verification logic and fixed my problem:
'verify' => true
You can also set this to false
if you don't care about the security of your SSL connection, but that's not a good solution.
Since the files in vendor
are not meant to be tampered with, a better solution would be to configure the Guzzle client on usage, but this was just too difficult to do in Laravel 4.
Hope this saves someone else a couple hours of debugging...
This might be an edge case, but in my case the problem was not the client conf (I already had curl.cainfo
configured in php.ini
), but rather the remote server not being configured properly:
It did not send any intermediate certs in the chain. There was no error browsing the site using Chrome, but with PHP I got following error.
cURL error 60
After including the Intermediate Certs in the remote webserver configuration it worked.
You can use this site to check the SSL configuration of your server:
https://whatsmychaincert.com/
If you're unable to change php.ini you could also point to the cacert.pem file from code like this:
$http = new GuzzleHttp\Client(['verify' => '/path/to/cacert.pem']);
$client = new Google_Client();
$client->setHttpClient($http);
Be sure that you open the php.ini
file directly by your Window Explorer. (in my case: C:\DevPrograms\wamp64\bin\php\php5.6.25
).
Don't use the shortcut to php.ini
in the Wamp/Xamp icon's menu in the System Tray. This shortcut doesn't work in this case.
Then edit that php.ini
:
curl.cainfo ="C:/DevPrograms/wamp64/bin/php/cacert.pem"
and
openssl.cafile="C:/DevPrograms/wamp64/bin/php/cacert.pem"
After saving php.ini
you don't need to "Restart All Services" in Wamp icon or close/re-open CMD.