Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

laravel - cURL error 60: SSL certificate problem: self signed certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

I use Guzzle in my Laravel 7 project and XAMPP 7.4.5, I'm trying to make a GET to my local API localhost/events_platforma/view/users It works fine but when I'm trying to make a POST request to https://localhost/events_platforma/register it fails and gives out that cURL error and My API Are on SLIM.

I have added this file

curl.cainfo = curl.cainfo="C:xamppphpextrassslcacert.pem"

But still, give out an error

question from:https://stackoverflow.com/questions/65882711/curl-error-60-ssl-certificate-problem-self-signed-certificate-see-https-cur

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The quick solution for localhost is to turn off the certificate verification using options in guzzle of verify as false.

A quick small example below

use GuzzleHttpClient;

$client = new Client([
    'base_uri' => 'http://exmaple.org'
]);
$client->request('GET', '/', ['verify' => false]);

If you are using Http-client provided by laravel you can add guzzle options like this,

$response = Http::withOptions([
    'verify' => false,
])->get('http://example.org/');

NOTE:

Though even guzzle suggests to not using it, but if you are testing your own apis it can work.


Though you can simple add your certificates as per request just by providing path.

Mozilla provides a commonly used CA bundle which can be downloaded here (provided by the maintainer of cURL).

// Use a custom SSL certificate on disk.
$client->request('GET', '/', ['verify' => '/path/to/cacert.pem']);

Read more about certificates from https://curl.se/docs/sslcerts.html .
Read more about verify from guzzle docs verify


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...