Wolrab Wolrab - 3 months ago 11
PHP Question

Laravel, Local Hosted cURL error 60: SSL certificate

I keep getting the error which calling an API locally, works fine on my server:


cURL error 60: SSL certificate problem: unable to get local issuer
certificate


Is there a way to stop this exception from showing locally?

Here's my code, ignore the () as this is variable info:

public function testCheck($domains){

$client = new Client();

$res = $client->request('GET', 'https://api.namecheap.com/xml.response?ApiUser=(username)&ApiKey=(apikey)&UserName(username)&ClientIp=(ip)&Command=namecheap.domains.check&DomainList=' . $domains);

$data = json_decode($res->getBody());

dd($data);

}


Is there a way to stop this exception from showing locally so I can carry on testing?

Answer

If you are testing locally you can disable the SSL verification:

// Disable validation entirely
$client->request('GET', '/', ['verify' => false]);

See the docs for more information: http://guzzle.readthedocs.io/en/latest/request-options.html#verify-option

However you should not use this for anything else than testing, in normal cases you should use a certificate and verify this certificate properly.