我如何解决 Symfony/Goutte 中的 SSL 问题
How can I fix the SSL problem in Symfony/Goutte
我正在尝试使用 Symfony/Goutte 向网站发出请求,但我收到了这样的错误:
In ErrorChunk.php line 65:
SSL peer certificate or SSH remote key was not OK for "https://example.com".
In CurlResponse.php line 298:
SSL peer certificate or SSH remote key was not OK for "https://example.com".
代码如下:
use Goutte\Client;
$client = new Client();
$client->request('GET', 'https://example.com');
如何解决这个问题?
您需要添加 HttpClient 并禁用 SSL 检查...(仅用于调试)不适用于生产!
use Goutte\Client;
use Symfony\Component\HttpClient\HttpClient;
$client = new Client(HttpClient::create(['verify_peer' => false, 'verify_host' => false]));
$client->request('GET', 'https://example.com');
我正在尝试使用 Symfony/Goutte 向网站发出请求,但我收到了这样的错误:
In ErrorChunk.php line 65:
SSL peer certificate or SSH remote key was not OK for "https://example.com".
In CurlResponse.php line 298:
SSL peer certificate or SSH remote key was not OK for "https://example.com".
代码如下:
use Goutte\Client;
$client = new Client();
$client->request('GET', 'https://example.com');
如何解决这个问题?
您需要添加 HttpClient 并禁用 SSL 检查...(仅用于调试)不适用于生产!
use Goutte\Client;
use Symfony\Component\HttpClient\HttpClient;
$client = new Client(HttpClient::create(['verify_peer' => false, 'verify_host' => false]));
$client->request('GET', 'https://example.com');