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命令:

获取可以验证远程服务器的CA证书并使用 适当的选项指出此CA证书进行验证时 连接。对于libcurl黑客:curl_easy_setopt(curl, CURLOPT_CAPATH capath); 使用curl命令行工具:——cacert[文件]


例如:

curl --cacert mycertificate.cer -v https://www.stackoverflow.com

其他回答

我通过在cURL脚本中添加一行代码解决了这个问题:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

警告:这使得请求绝对不安全(参见@YSU的回答)!

输入这两个代码以禁用SSL证书颁发。这对我很有效 经过大量研究,我发现了这个。

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

我也遇到过这个问题。我读了这篇文章,大部分答案都很有信息量,但对我来说太复杂了。我在社交话题上没有经验,所以这个答案适合像我这样的人。

在我的例子中,发生这个错误是因为我没有在应用程序中使用的证书旁边包含中间证书和根证书。

以下是我从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-----

请注意,证书之间、文件的末尾或开头没有空格。一旦您向应用程序提供了这个组合证书,您的问题就会得到解决。

在亚马逊Linux (CentOS / Red Hat等)上,我做了以下工作来解决这个问题。首先复制cacert。Pem从http://curl.haxx.se/ca/cacert.pem下载,放在/etc/pki/ca-trust/source/anchors/目录下。执行update-ca-trust命令。

下面是来自https://serverfault.com/questions/394815/how-to-update-curl-ca-bundle-on-redhat的一句话

Curl https://curl.se/ca/cacert.pem -o /etc/pki/ca-trust/source/anchors/curl-cacert-updated。Pem && update-ca-trust

然而,由于curl被破坏,我实际上使用这个命令来下载cacert。pem文件。

Wget——no-check-certificate http://curl.haxx.se/ca/cacert.pem

另外,如果你在使用php时遇到了问题,你可能需要重新启动你的web服务器服务httpd restart for apache或service nginx restart for nginx。

由于conda环境,一些系统可能存在此问题。如果你安装了conda,那么禁用它可以解决你的问题。在我的情况下,当我停用conda时,这个curl-SSL错误得到了解决。在ubuntu或MacOS上试试这个命令

conda deactivate