【问题标题】:OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failedOpenSSL 错误消息:错误:1416F086:SSL 例程:tls_process_server_certificate:证书验证失败
【发布时间】:2019-12-12 22:40:48
【问题描述】:

我在 Windows 10 计算机和 Composer 版本 1.9.0 上使用 PHP v7.2

composer create-project --prefer-dist laravel/laravel blog

我正在尝试安装 Laravel 并使用 composer 启动一个项目,但收到以下错误

OpenSSL 错误消息: 错误:1416F086:SSL 例程:tls_process_server_certificate:证书验证失败

当我运行composer diagnose 时得到以下结果

PS C:\xampp\htdocs\webstore_services> 作曲家诊断 检查平台设置:OK 检查 git 设置:好的 检查与 packagist 的 http 连接:警告:通过 http 访问 192.168.1xx.2xx,这是一个不安全的协议。 好的 检查到 packagist 的 https 连接:[Composer\Downloader\TransportException] 无法下载“https://repo.packagist.org/packages.json”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息: 错误:1416F086:SSL 例程:tls_process_server_certificate:证书验证失败 无法启用加密 无法打开流:操作失败 检查 github.com 速率限制:FAIL [Composer\Downloader\TransportException] 无法下载“https://api.github.com/rate_limit”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息: 错误:1416F086:SSL 例程:tls_process_server_certificate:证书验证失败 无法启用加密 无法打开流:操作失败 检查磁盘可用空间:OK 检查公钥: 标签公钥指纹:57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642 开发公钥指纹:4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952 好的 检查作曲家版本: [作曲家\下载器\TransportException]
无法下载“https://getcomposer.org/versions”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息:
错误:1416F086:SSL 例程:tls_process_server_certificate:证书验证失败
启用加密失败
无法打开流:操作失败
诊断

我几乎尝试了互联网上的所有解决方案

php -r "print_r(openssl_get_cert_locations());"

结果

(
    [default_cert_file] => C:\usr\local\ssl/cert.pem
    [default_cert_file_env] => SSL_CERT_FILE
    [default_cert_dir] => C:\usr\local\ssl/certs
    [default_cert_dir_env] => SSL_CERT_DIR
    [default_private_dir] => C:\usr\local\ssl/private
    [default_default_cert_area] => C:\usr\local\ssl
    [ini_cafile] => C:\xampp\php\cacert.pem
    [ini_capath] => C:\xampp\php\cacert.pem
)

我将如何更改default_cert_file在此的位置,只剩下这个?

由于我使用的是企业代理,因此我设置了代理的 env 变量。

https_proxy:http://user:pass@host:port http_proxy : http://user:pass@host:port

虽然我做了所有事情,但它对我没有帮助。

【问题讨论】:

  • 我的电脑时间正确
  • 尝试使用服务器证书和 cacert.pem 证书列表将您的问题简化为 openssl verify 命令。类似“openssl verify -CAfile cacert.pem -untrusted server.pem server.pem”的东西。我猜,您的服务器证书中没有中间证书。 openssl.org/docs/man1.1.1/man1/verify.html
  • 我也有这个确切的问题。 composer 1.8.5,也在企业防火墙后面。不使用laravel。运行composer self-update 时是否也会报错?类似于:无法下载“getcomposer.org/versions”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:1416F086:SSL 例程:tls_process_server_certificate:certificate verify failed 无法启用加密无法打开流:操作失败
  • @Protomancer 是的,我在composer self-update得到了这个问题

标签: php laravel openssl xampp composer-php


【解决方案1】:

我不知道会不会回答你,但我会尽力启发你:

这是一个安全连接失败: default_cert_file 是在生成证书时定义的

error:1416F086:SSL 是一个类似的错误 服务器拒绝了您的证书,因为它已被吊销、不存在或不正确 当安全证书无效或不再有效时,浏览器中可能会出现相同错误,错误代码为 SSL_ERROR_REVOKED_CERT_ALERT 或 SSL_ERROR_HANDSHAKE_FAILURE_ALER

当您生成根证书时,这可能取决于配置文件,其中指定了多个信息,尤其是路径:

[CA_default] dir = ./certificats #所有东西都保存在哪里

openssl 等 ...

我认为你正在寻找的是类似的

SSL 上下文选项 SSL 上下文选项 — SSL 上下文选项列表

文件字符串

Location of Certificate Authority file on local filesystem which should be used with the verify_peer context option to authenticate the identity of the remote peer.

capath 字符串

If cafile is not specified or if the certificate is not found there, the directory pointed to by capath is searched for a suitable certificate. capath must be a correctly hashed certificate directory.

【讨论】:

    【解决方案2】:

    此错误的最常见原因是日期/时间不同步,请检查您机器的本地时间并使用 ntp 或 chrony 等命令来同步您的时间。

    如果您在 docker 容器中遇到此问题,则该容器将使用您的主机时间。但是,将计算机置于休眠模式会使时间锁定。唯一的解决办法是重新启动整个计算机。

    【讨论】:

    • 嘿我的机器本地时间和服务器时间是一样的。
    • 非常感谢这是我在使用 gRPC 的 Ubuntu 设置上遇到的问题
    • @MewTwo 也检查时区
    猜你喜欢
    • 2019-04-08
    • 2018-12-21
    • 2021-09-04
    • 1970-01-01
    • 2017-05-21
    • 2020-09-20
    • 2015-11-08
    • 2019-04-20
    相关资源
    最近更新 更多