gpt4 book ai didi

php - 如何修复 "Unable to connect to https://127.0.0.1 SSL certificate problem: self signed certificate"

转载 作者:行者123 更新时间:2023-12-04 19:05:56 28 4
gpt4 key购买 nike

我知道有几篇关于这个主题的帖子,但我尝试了很多,但没有任何效果。

    curl_setopt($ch, CURLOPT_URL, "https://127.0.0.1:2288");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $pRequest);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CAINFO, "/etc/ssl/certs/cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '2');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
当我在 Ubuntu 20.04 机器上执行它时,我得到这个错误:
Fatal error: Uncaught RuntimeException: Unable to connect to https://127.0.0.1:2288/ Error: SSL certificate problem: self signed certificate
证书是 curl.se/docs/caextract.html 中的当前版本
php.ini:
extension=curl
extension=php_curl.dll
curl.cainfo="/etc/ssl/certs/cacert.pem"
如果不禁止 curl ssl 连接,我还能做什么?

最佳答案

如果您使用自签名证书,则必须将其添加到受信任的证书中,或者必须关闭验证。
对于第二种情况,只需将 CURLOPT_SSL_VERIFYPEER 切换为 false。

关于php - 如何修复 "Unable to connect to https://127.0.0.1 SSL certificate problem: self signed certificate",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69597045/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com