Laragon 下的 PHP - SSL 操作失败,代码为 1

标签 php ssl laragon

我正在使用 Laragon在 Windows 10 上使用 PHP 开发的 4.0.16。
我使用 Laragon 工具启用了 SSL:
enter image description here
还将 laragon.crt 添加到 Trust Store。
enter image description here
我可以通过 https://project.test 访问我的测试项目正确。
但是,有一个问题:

Warning: getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed


我一直在阅读解决此类问题的方法是在 PHP ini 配置文件中设置 curl.cainfo 和 openssl.cafile。
我这样做了,在位于 C:\laragon\bin\php\php-xxx\php.ini 的 Laragon 全局 php.ini 中:
curl.cainfo = "C:\laragon\etc\ssl\cacert.pem"
openssl.cafile = "C:\laragon\etc\ssl\cacert.pem"
但重启 Laragon 后,php 警告仍然存在。
我还能做些什么来追踪问题并解决它?
谢谢你。

最佳答案

我花了几个小时试图弄清楚这个问题。
我找到的所有解决方案都说明了以下几点:

  • https://curl.haxx.se/ca/cacert.pem 下载 cacert并替换 laragon/etc/ssl/
  • 中的那个
  • 将 php.ini 中的 openssl.cafile 设置为 laragon\etc\ssl\laragon.crt(例如 openssl.cafile= "C:\laragon\etc\ssl\laragon.crt")

  • 根本没有帮助。真正起作用的是切换到 php 7.3(我的代码无法运行 7.4,我在那里遇到了不同的错误)。
    原因似乎是对于 php 7.2.19,php_openssl.dll 的版本为 1.1.1b,而 7.3 及更高版本的 php_openssl.dll 的版本为 1.1.1k。
    这终于解决了这个问题。我希望这可以帮助某人几个小时的疯狂。我不确定这是否会在 future 的 php 版本中再次发生 :)

    关于Laragon 下的 PHP - SSL 操作失败,代码为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63014355/

    相关文章:

    php - 限制检索的行数 MySql, Laravel

    ssl - session 为 : <sessionid>, 的项目报告路径为 : , 用户名:<用户名> 在数据库中未找到

    twitter-bootstrap - IE Bootstrap 字体(图标)未加载

    apache - 我如何在 laragon 中将 HTTP 重定向到 HTTPS

    php - laravel 的组域路由在 laragon 中不起作用

    mysql - 拉拉贡 :How to import large mysql dump

    php - 在kali linux的LAMP上安装zf2?

    php - 插入 pdo 前清空表

    Python httplib 禁用证书验证

    php - 基于 php 中的键查找值的有效方法