PHP 使用 LetsEncrypt 验证失败

PHP verify failed with LetsEncrypt

尝试读取流时遇到问题:

$result = file_get_contents($url, false, stream_context_create(
    ['http' => ['timeout' => (float) $this->options['timeout']]]
));

SSL operation failed with code 1. OpenSSL Error messages:

error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

在任何人回答之前我不会做

 "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),

我希望其他人已经使用了 letsencrypt 并且有一些正确的方法来确保它的有效性。

随时检查我的域名证书 lukepolo.com

您可能必须安装 CA 证书 (this page has links to download the CA file)。您可能必须尝试各种签名才能使其正常工作。获取 PEM 版本并将其保存到您的服务器,然后像这样更改您的代码

$result = file_get_contents($url, false, stream_context_create(
    [
        'http' => ['timeout' => (float) $this->options['timeout']],
        'ssl' => ['cafile' => '/path/to/file.pem']
    ]
));

openssl.cafile= curl.cainfo=

在你的php.ini中,你需要两者