PHP サーバー

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

※本サイトはPR表記を含みます。

 

スクレイピングライブラリのGoutte。Goutte3系を使っている最中、予期せぬエラーに遭遇しました。

 error
Exception: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c /libcurl-errors.html)

どうやら、SSL証明書の不備が疑われるのですが、エラーを回避する方法として、証明書の検証を無視するという方法が一つあります。正義ではない。

use Goutte\Client;

// HTTPS証明書の検証を無視する
$client = new Client();
$client->setClient(new \GuzzleHttp\Client([
    \GuzzleHttp\RequestOptions::VERIFY => false,
]));

で、回避できます。

ちなみにVERIFYにはSSL証明書のパスを指定できるようです。

vendor/guzzlehttp/guzzle/src/RequestOptions.php 232行目あたり

/**
* verify: (bool|string, default=true) Describes the SSL certificate
* verification behavior of a request. Set to true to enable SSL
* certificate verification using the system CA bundle when available
* (the default). Set to false to disable certificate verification (this
* is insecure!). Set to a string to provide the path to a CA bundle on
* disk to enable verification using a custom certificate.
*/
const VERIFY = 'verify';

 

-PHP, サーバー
-