root@sclrdev:/home/sclr/certs/FreshCerts# curl --ftp-ssl --verbose ftp://{abc}/ -u trup:trup --cacert /etc/ssl/certs/ca-certificates.crt
* About to connect() to {abc} port 21 (#0)
* Trying {abc}...
* Connected to {abc} ({abc}) port 21 (#0)
< 220-Cerberus FTP Server - Home Edition
< 220-This is the UNLICENSED Home Edition and may be used for home, personal use only
< 220-Welcome to Cerberus FTP Server
< 220 Created by Cerberus, LLC
> AUTH SSL
< 234 Authentication method accepted
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS alert, Server hello (2):
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
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.
当前回答
我在Wordpress安装上试图通过ElasticPress和AWS ACM PCA管理的自签名根CA与内部ElasticSearch服务通信,已经为这个问题困扰了几天。
在我的特殊情况下,我从默认的cURL传输以及预期的正文中收到了200 OK响应,但Wordpress返回了一个WP_Error对象,ElasticPress由于这个证书问题而获得,但从未记录。
说到Wordpress,有两件事值得注意:
The default cURL Transport for all wp_remote_* calls will look to a CA Bundle located in wp-includes/certificates/ca-bundle.crt. This bundle serves largely the same purpose as what's found under https://curl.haxx.se/docs/caextract.html, and will cover most use-cases that don't typically involve more exotic setups. Action/Filter order matters in Wordpress, and in ElasticPress' case, many of its own internal functions leverage these remote calls. The problem is, these remote calls were being executed during the plugins_loaded lifecycle, which is too early for Theme logic to be able to override. If you're using any plugins that make external calls out to other services and you need to be able to modify the requests, you should take careful note as to WHEN these plugins are performing these requests.
这意味着,即使在主题中定义了正确的服务器设置、钩子、回调和逻辑,你仍然可能以一个坏的设置结束,因为底层插件调用在主题加载之前执行得很好,并且永远无法告诉Wordpress关于新证书的信息。
在Wordpress应用程序中,我知道只有两种方法可以在不更新核心或第三方代码逻辑的情况下规避这个问题:
(推荐)添加一个“必须使用”插件到您的安装,调整您需要的设置。MU插件是Wordpress生命周期中最早加载的,可以让你在不直接改变它们的情况下覆盖你的插件和核心。在我的例子中,我用下面的逻辑建立了一个简单的MU插件:
// ep_pre_request_args is an ElasticPress-specific call that we need to adjust for all outbound HTTP requests
add_filter('ep_pre_request_args', function($args){
if($_ENV['ELASTICSEARCH_SSL_PATH'] ?? false) {
$args['sslcertificates'] = $_ENV['ELASTICSEARCH_SSL_PATH'];
}
return $args;
});
(不推荐)如果你实在没有其他选择,你也可以将根CA附加到wp-includes/certificates/ CA -bundle.crt。这似乎会“纠正”潜在的问题,你将得到正确的SSL证书验证,但这种方法将失败每次更新Wordpress,除非你添加额外的自动化。
我添加这个答案是因为在我甚至懒得深入研究插件源代码之前,我已经认为我在我的设置中做了一些错误或不稳定的事情。希望这可以为正在做类似事情的人节省一些时间。
其他回答
有这个问题,但新版本没有解决。/etc/certs有根证书,浏览器说一切正常。经过一些测试后,我从ssllabs.com得到警告,我的链是不完整的(实际上这是旧证书链,而不是新证书链)。在纠正了证书链之后,一切都很好,即使是curl。
这可以帮助你控制暴饮暴食:
$client = new Client(env('API_HOST'));
$client->setSslVerification(false);
测试在guzzle/guzzle 3.*
输入这两个代码以禁用SSL证书颁发。这对我很有效 经过大量研究,我发现了这个。
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
下载https://curl.haxx.se/ca/cacert.pem 下载后,将该文件移动到wamp服务器。 对于exp: D:\wamp\bin\php\ 然后在底部的php.ini文件中添加以下代码行。
curl.cainfo=“D:\wamp\bin\php\cacert.pem”
现在重新启动wamp服务器。
没有一个答案提到,可能是连接到内部vpn的角色,我以前遇到过这个问题,并要求在专用网络上
推荐文章
- Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)
- PHP中的cURL是什么?
- 错误:无法验证nodejs中的第一个证书
- 对bash脚本函数中定义的变量使用curl POST
- 没有为Android SSL连接找到信任锚
- 抓取:SSL: CERTIFICATE_VERIFY_FAILED错误http://en.wikipedia.org
- 使用curl POST multipart/form-data的正确方法是什么?
- 使用.htaccess和mod_rewrite强制SSL/https
- PHP -调试Curl
- (1) libcurl不支持或禁用https协议
- 在尝试访问HTTPS url时,如何使用cURL处理证书?
- 在Java客户端中接受服务器的自签名ssl证书
- 如何使用PHP 7安装ext-curl扩展?
- 如何通过JSON文件传递有效载荷卷曲?
- 编写器安装错误——当它实际启用时需要ext_curl