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.
当前回答
我通过在cURL脚本中添加一行代码解决了这个问题:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
警告:这使得请求绝对不安全(参见@YSU的回答)!
其他回答
这很可能是服务器上丢失的证书。
根- >中间- >服务器
服务器至少应该发送服务器和中间体。
使用openssl s_client -showcerts -starttls ftp -crlf -connect abc:21进行调试。
如果只返回一个证书(自签名或颁发),那么您必须选择:
修复服务器 信任该证书并将其添加到您的CA证书存储(不是最好的主意) 禁用信任,例如curl -k(非常糟糕的主意)
如果服务器返回多个,但不包括自签名(根)证书:
在此链的CA存储中安装CA(根)证书,例如谷歌颁发者。(只有当你信任该CA时) 服务器是否将CA作为链的一部分发送 信任链中的证书 禁用的信任
如果服务器返回一个根CA证书,那么它不在您的CA存储中,您的选项是:
添加(信任)它 禁用的信任
我忽略了过期/撤销的证书,因为没有消息表明它。但是您可以使用openssl x509 -text检查certs
假设您正在连接到家庭版(https://www.cerberusftp.com/support/help/installing-a-certificate/) ftp服务器,我将说它是自签名的。
请发布更多细节,比如来自openssl的输出。
我也遇到过这个问题。我读了这篇文章,大部分答案都很有信息量,但对我来说太复杂了。我在社交话题上没有经验,所以这个答案适合像我这样的人。
在我的例子中,发生这个错误是因为我没有在应用程序中使用的证书旁边包含中间证书和根证书。
以下是我从SSL证书供应商那里得到的信息:
- abc.crt
- abc.pem
- abc-bunde.crt
在abc。CRT文件,只有一个证书:
-----BEGIN CERTIFICATE-----
/*certificate content here*/
-----END CERTIFICATE-----
如果我以这种格式提供它,浏览器将不会显示任何错误(Firefox),但我会得到curl:(60) SSL证书:无法获得本地颁发者证书错误时,我做curl请求。
要修复此错误,请检查abc-bunde。crt文件。你很可能会看到这样的东西:
-----BEGIN CERTIFICATE-----
/*additional certificate content here*/
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
/*other certificate content here*/
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
/*different certificate content here*/
-----END CERTIFICATE-----
这些是您的中级证书和根证书。发生错误是因为您提供给应用程序的SSL证书中缺少它们。
要修复此错误,请以以下格式合并这两个文件的内容:
-----BEGIN CERTIFICATE-----
/*certificate content here*/
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
/*additional certificate content here*/
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
/*other certificate content here*/
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
/*different certificate content here*/
-----END CERTIFICATE-----
请注意,证书之间、文件的末尾或开头没有空格。一旦您向应用程序提供了这个组合证书,您的问题就会得到解决。
我的情况不同。我在防火墙后面托管一个网站。错误是由pfSense引起的。
Network layout: |Web Server 10.x.x.x| <-> |pfSense 49.x.x.x| <-> |Open Internet|
多亏了这个答案,我意外地找到了原因。
当我从广域网访问我的网站时,一切都很好。
然而,当从局域网内访问站点时(例如,当Wordpress向其自己的服务器发出curl请求时,尽管使用WAN IP 49.x.x.x),它被提供pfSense登录页面。
我将证书标识为pfSense webConfigurator自签名证书。难怪curl抛出一个错误。
原因:发生的事情是curl正在使用站点的WAN IP地址49.x.x.x。但是,在web服务器的上下文中,广域网IP是防火墙。
调试:我发现我正在获得pfSense证书。
解决方案:在托管该站点的服务器上,将其自己的域名指向127.0.0.1
通过应用该解决方案,web服务器正确地处理了curl的请求,并且没有转发到防火墙,防火墙通过发送登录页面进行响应。
关于“SSL证书问题:无法获得本地颁发者证书”错误。需要注意的是,这适用于发送CURL请求的系统,而不是接收请求的服务器。
Download the latest cacert.pem from https://curl.se/ca/cacert.pem Add the '--cacert /path/to/cacert.pem' option to the curl command to tell curl where the local Certificate Authority file is. (or) Create or add to a '.curlrc' file the line: cacert = /path/to/cacert.pem See 'man curl', the section about the '-K, --config <file>' section for information about where curl looks for this file. (or if using php) Add the following line to php.ini: (if this is shared hosting and you don't have access to php.ini then you could add this to .user.ini in public_html).
卷毛。cainfo = " - path / to / downloaded cacert pem。”
请确保将路径用双引号括起来!!
默认情况下,FastCGI进程将每300秒解析一次新文件(如果需要,您可以通过添加几个文件来改变频率https://ss88.uk/blog/fast-cgi-and-user-ini-files-the-new-htaccess/)。
尝试在Ubuntu中重新安装curl,并使用sudo update-ca-certificates—fresh更新我的CA证书
推荐文章
- CMake无法找到OpenSSL库
- 如何为已安装的Ubuntu LAMP堆栈启用cURL ?
- 从PKCS12文件中提取公钥/私钥,供以后在SSH-PK-Authentication中使用
- PHP获取网站URL协议- http vs https
- 为什么cURL返回错误“(23)Failed writing body”?
- 如何POST JSON数据与PHP卷曲?
- 使用curl在PHP中获取HTTP代码
- SSL握手警告:unrecognized_name错误,因为升级到Java 1.7.0
- SSL证书错误:无法获得本地颁发者证书
- "ERROR:root:code for hash md5 was not found"当使用任何hg mercurial命令时
- 我需要做什么才能使ie8接受自签署证书?
- 使用请求包时出现SSL InsecurePlatform错误
- BEGIN RSA PRIVATE KEY与BEGIN PRIVATE KEY的区别
- 从URL执行bash脚本
- 你从哪里包含jQuery库?谷歌JSAPI吗?CDN吗?