//代码如下 网址做了马赛克
$response = \Http::get('https://example.com');
报错如下
GuzzleHttp\Exception\RequestException cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
CURLE_PEER_FAILED_VERIFICATION (60)
The remote server's SSL certificate or SSH md5 fingerprint was deemed not OK. This error code has been unified with CURLE_SSL_CACERT since 7.62.0. Its previous value was 51.
方法一(永久
)禁用https验证就行
找到vendor\guzzlehttp\guzzle\src\Client.php 下的 configureDefaults
方法,把verify
修改为false
private function configureDefaults(array $config)
{
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
//'verify' => true,
'verify' => false,//禁用https验证
'cookies' => false
];
.....
}
方法二 请求时加上withoutVerifying
方法如下
$response = \Http::withoutVerifying()->get('https://example.com');
详细方法在 vendor\laravel\framework\src\Illuminate\Http\Client\PendingRequest.php中