Php curl服务器证书验证失败

Php curl服务器证书验证失败,php,linux,ssl,curl,Php,Linux,Ssl,Curl,我有一堆PHP脚本,它们使用curl与各种服务进行通信。目前,其中一个服务的SSL证书已更新,当我尝试从服务器的CLI获取该证书时,我的curl开始为此哭泣: ~$ curl https://example.com curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none More details here: http://curl.ha

我有一堆PHP脚本,它们使用curl与各种服务进行通信。目前,其中一个服务的SSL证书已更新,当我尝试从服务器的CLI获取该证书时,我的curl开始为此哭泣:

~$ curl https://example.com

curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL).

If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
目前,我对所有请求都硬编码了verify=>false,以保持脚本的运行,但这不是我想要解决的问题

我得到了最新的证书,把它放在/etc/ssl/certs/ca-certificates.crt中,然后运行sudo update ca certificates,我想它已经成功运行了

~$ sudo update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
但是,curl对此也不太满意,仍然无法在不传递-k标志的情况下获取我的资源。

您可以使用openssl s_client命令进一步调试该问题,以找出证书的确切问题

openssl s_client -showcerts -servername myservice.com -connect myservice.com:443
您可以使用openssl s_client命令进一步调试该问题,以便找出证书的确切问题

openssl s_client -showcerts -servername myservice.com -connect myservice.com:443

这是一些有用的信息,谢谢。它显示verify error:num=18:self signed certificate,但该证书显然不是自签名的,它是一个COMODO证书。有点可疑。能否使用附加参数-servername myservice.com重试,这可能与?现在错误变成了验证返回代码:21无法验证第一个证书,因此我认为这是一个配置不正确的服务器,我必须向服务维护人员提出问题,除了跳过验证之外,我什么也做不了。是,假定ca证书未与证书文件正确绑定。只需将证书颁发机构crt粘贴到与证书相同的文件中,然后重新启动Web服务器。可能是nginx。这是一些有用的信息,谢谢。它显示verify error:num=18:self signed certificate,但该证书显然不是自签名的,它是一个COMODO证书。有点可疑。能否使用附加参数-servername myservice.com重试,这可能与?现在错误变成了验证返回代码:21无法验证第一个证书,因此我认为这是一个配置不正确的服务器,我必须向服务维护人员提出问题,除了跳过验证之外,我什么也做不了。是,假定ca证书未与证书文件正确绑定。只需将证书颁发机构crt粘贴到与证书相同的文件中,然后重新启动Web服务器。Stack Overflow可能是一个关于编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参见帮助中心中的。堆栈溢出是一个解决编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参见帮助中心中的。也许或者会是一个更好的提问的地方。