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.
与“SSL证书问题:无法获取本地颁发者证书”错误有关。显然这适用于发送CURL请求的系统(并且没有服务器接收请求)
1)从https://curl.haxx.se/ca/cacert.pem下载最新的cacert.pem
2)将以下行添加到php.ini(如果这是共享主机,您无权访问php.ini,那么您可以将其添加到public_html中的.user.ini)
curl.cainfo="/path/to/downloaded/cacert.pem"
确保将路径括在双引号内!
3)默认情况下,FastCGI进程将每300秒解析一次新文件(如果需要,您可以通过添加几个文件来更改频率,如https://ss88.uk/blog/fast-cgi-and-user-ini-files-the-new-htaccess/所示)
在Windows上我遇到了这个问题。 Curl由mysysgit安装,因此下载并安装最新版本修复了我的问题。
否则这些是关于如何更新您可以尝试的CA证书的正确的instructions。
是的,您还需要添加CA证书。在Node.js中添加代码片段以获得清晰视图。
var fs = require(fs)
var path = require('path')
var https = require('https')
var port = process.env.PORT || 8080;
var app = express();
https.createServer({
key: fs.readFileSync(path.join(__dirname, './path to your private key/privkey.pem')),
cert: fs.readFileSync(path.join(__dirname, './path to your certificate/cert.pem')),
ca: fs.readFileSync(path.join(__dirname, './path to your CA file/chain.pem'))}, app).listen(port)
在Windows上 - 如果你从cmd运行
> curl -X GET "https://some.place"
从https://curl.haxx.se/docs/caextract.html下载cacert.pem
设置环境变量:
CURL_CA_BUNDLE = C:\Program Files\curl-7.57.0\src\cacert.pem
和重新加载环境
refreshenv
现在再试一次
我的情况不同了。我正在托管防火墙后面的网站。该错误是由pfSense引起的。
Network layout: |Web Server 10.x.x.x| <-> |pfSense 49.x.x.x| <-> |Open Internet|
由于this answer,我意外地找到了原因。
当我从WAN访问my site时一切都很好。
但是,当从局域网内部访问该站点时(例如,当Wordpress向其自己的服务器发出curl
请求时,尽管使用了WAN IP 49.x.x.x
),它仍然在pfSense登录页面上提供。
我将证书确定为pfSense webConfigurator Self-Signed Certificate
。难怪curl
犯了一个错误。
原因:发生了什么是curl
使用该网站的WAN IP地址49.x.x.x
。但是,在Web服务器的环境中,WAN IP是防火墙。
调试:我发现我获得了pfSense证书。
解决方案:在托管站点的服务器上,将其自己的域名指向127.0.0.1
通过应用该解决方案,curl
的请求由Web服务器正确处理,而不是通过发送登录页面转发到响应的防火墙。
到目前为止,我已经看到这个问题发生在公司网络中,原因有两个,其中一个或两个可能在您的情况下发生:
作为附注,上面的第2条可能会让您对所谓的安全TLS流量被扫描感到不安。那是你的企业世界。
有这个问题,它没有用更新版本解决。 / etc / certs有root证书,浏览器说一切都很好。经过一些测试后,我从ssllabs.com得到了警告,我的链条没有完整(事实上它是旧证书的链条,而不是新的证书链)。纠正证书链后,一切都很好,即使是卷曲。
特别是对于Windows
用户,使用curl-7.57.0-win64-mingw
或类似版本。
这有点晚了,现有的答案是正确的。但我仍然需要努力让它在我的Windows机器上工作,尽管这个过程实际上非常简单。所以,分享一步一步的过程。
这个错误基本上意味着,curl无法验证目标URI的证书。如果您信任证书(CA)的颁发者,则可以将其添加到受信任证书列表中。
为此,浏览URI(例如在Chrome上)并按照步骤操作
.cer
文件并复制内容(包括----- BEGIN CERTIFICATE -----和----- END CERTIFICATE -----)curl.exe
的目录,例如C:\SomeFolder\curl-7.57.0-win64-mingw\bin
curl-ca-bundle.crt
文件现在你的命令应该在curl中正常执行。
这可以帮助你guzzle:
$client = new Client(env('API_HOST'));
$client->setSslVerification(false);
在guzzle / guzzle 3上测试。*
简单的解决方案:在~/.sdkman/etc/config
,改变sdkman_insecure_ssl=true
脚步:
纳米~/.sdkman/etc/config
将sdkman_insecure_ssl=false
改为sdkman_insecure_ssl=true
保存并退出
由于cURL无法验证服务器提供的证书,因此失败。
有两种方法可以使其工作:
-k
选项一起使用,允许curl进行不安全的连接,即cURL不验证证书。etc/ssl/certs/ca-certificates.crt
您应该使用选项2,因为它是确保您连接到安全FTP服务器的选项。
我通过在cURL脚本中添加一行代码解决了这个问题:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
警告:这使得请求绝对不安全(请参阅@YSU的回答)!
安装Git Extensions v3.48后出现此问题。试图再次安装mysysgit但同样的问题。最后,不得不禁用(请考虑安全隐患!)Git SSL验证:
git config --global http.sslVerify false
但如果您有域名证书,请将其添加到(Win7)
C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt
在我的情况下,在我尝试使用cURL使用的服务上安装我的证书时,结果证明是个问题。我无法将中间证书和根证书捆绑/连接到我的域证书中。起初并不是很明显,这是问题所在,因为尽管省略了中间证书和根证书,Chrome仍然将其解决并接受了证书。
捆绑证书后,一切都按预期工作。我捆绑了这样的
$ cat intermediate.crt >> domain.crt
并重复所有中间和根证书。
我们最近遇到了这个错误。事实证明它与根证书没有正确安装在CA商店目录中有关。我正在使用curl命令直接指定CA dir。 curl --cacert /etc/test/server.pem --capath /etc/test ...
每次使用curl时此命令失败:(60)SSL证书问题:无法获得本地颁发者证书。
在使用strace curl ...
之后,确定curl正在查找名为60ff2731.0的根证书文件,该文件基于openssl哈希命名对话。所以我发现这个命令可以有效地导入根证书:
ln -s rootcert.pem`openssl x509 -hash -noout -in rootcert.pem`.0
这会创建一个软链接
60ff2731.0 - > rootcert.pem
curl,在封面下读取server.pem证书,确定根证书文件(rootcert.pem)的名称,将其转换为其哈希名称,然后执行操作系统文件查找,但找不到它。
因此,需要注意的是,当curl错误模糊不清时运行curl时使用strace(这是一个巨大的帮助),然后确保使用openssl命名约定正确安装根证书。
它很可能是服务器缺少的证书。
根 - >中程>服务器
服务器应至少发送Server&Intermediate。
使用openssl s_client -showcerts -starttls ftp -crlf -connect abc:21
来调试问题。
如果只返回一个证书(自签名或已签发),则必须选择:
curl -k
(非常糟糕的主意)如果服务器返回多个,但不包括自签名(root)证书:
如果服务器返回了根CA证书,那么它不在您的CA商店中,您的选项是:
我忽略了过期/撤销的证书,因为没有消息表明它。但您可以使用openssl x509 -text
检查证书
鉴于您正在连接到家庭版(https://www.cerberusftp.com/support/help/installing-a-certificate/)ftp服务器,我将说它是自签名的。
请发布更多详细信息,例如openssl的输出。
对我来说,简单安装证书有助于:
sudo apt-get install ca-certificates
根据cURL docs,您还可以将证书传递给curl
命令:
获取可以验证远程服务器的CA证书,并在连接时使用正确的选项指出此CA证书以进行验证。对于libcurl黑客:curl_easy_setopt(curl,CURLOPT_CAPATH,capath);
使用curl命令行工具:
--cacert [file]
例如:
curl --cacert mycertificate.cer -v https://www.google.com