【问题标题】:curl: (60) Peer's Certificate issuer is not recognizedcurl: (60) Peer\'s Certificate issuer is not recognized
【发布时间】:2023-01-23 19:30:14
【问题描述】:

我正在尝试按照“.NET Tutorial - Hello World in 5 minutes”中的说明在 Centos 7 上安装 .net Core SDK 2.0.0。

当我运行第一个命令时

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

我收到此错误:

curl: (60) Peer's Certificate issuer is not recognized.
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.
error: https://packages.microsoft.com/keys/microsoft.asc: import read failed(2)

我在公司代理后面,这个错误似乎与 SSL 证书和卷曲有关,但我不知道如何修复它。

此外,当我使用 curl 或 wget 下载 HTTPS URL 时,我也会遇到类似的错误。

【问题讨论】:

    标签: curl https .net-core


    【解决方案1】:

    我遇到了同样的问题,然后只是暂时关闭了 SSL 检查并安装了软件包。但请注意,这是绕过安全措施,因此请谨慎使用。

    sudo vi /etc/yum.conf 
    

    然后在编辑器上添加以下行

    sslverify=false
    

    【讨论】:

    • 对我来说就像宝石一样工作。谢谢。
    • 我需要 sslverify=0
    【解决方案2】:

    终于修好了。在这里发布答案作为参考。

    • 获取公司可信根证书的副本
    • 如果不是 PEM 格式,请转换它。 (例如,对于 DER 运行 openssl x509 -in xxx.cer -inform der -outform pem -out xxx.pem
    • 安装 ca-certificates 包:yum install ca-certificates
    • 启用动态CA配置功能:update-ca-trust force-enable
    • 将根证书放在/etc/pki/ca-trust/source/anchors/
    • 运行update-ca-trust extract将根添加到系统的可信证书中

    参考:

    https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them

    http://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html

    【讨论】:

    • 您怎么知道必须将它们转换为 .pem?您引用的链接使您看起来可以添加 .crt 并更新 CA 存储,与转换无关。
    • 请阅读“Link-only answers”。我们需要知道那些有用的链接是什么。没有那个,什么时候链接腐烂和死亡它们将毫无意义,可能使您的答案毫无意义;此时第一个链接已经死了。而且,虽然自己回答问题是件好事,但请务必描述为什么答案是正确的解决方案。如果做不到,请选择最有帮助的答案。
    • @theTinMan 这几乎不是仅链接的答案。它提供了一组要遵循的详细步骤,其中的链接清楚地标识为源材料。
    【解决方案3】:

    检查您的服务器是否具有有效的代理设置。

    【讨论】:

    • 欢迎来到 SO。这似乎没有回答 OP,可以作为评论发布。请查看how-to-answer了解更多详情。
    • 对于我当前的问题,实际上这是最有用的答案。
    【解决方案4】:

    我使用的自签名 SSL 证书已过期,因此在 Cent OS 7 上我运行以下命令,但将天数从 -days 365 增加到 -days 1400,这大约是 4 年保证。

    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
    

    您可以在“How To Create an SSL Certificate on Apache for CentOS 7”中找到更多信息。

    【讨论】:

    【解决方案5】:
    cd /etc/pki/ca-trust/extracted/pem
    mv tls-ca-bundle.pem tls-ca-bundle.pem.back
    wget --no-check-certificate https://curl.se/ca/cacert.pem
    mv cacert.pem tls-ca-bundle.pem
    

    【讨论】:

    • 参见“Explaining entirely code-based answers”。虽然这在技术上可能是正确的,但它并不能解释为什么它可以解决问题或应该是选定的答案。我们应该在帮助解决问题的同时进行教育。
    • @theTinMan 很奇怪!嗯,很明显,它解决了被问到的问题!!!并且不需要额外的解释,因为说明是透明的。如果我需要解释,我一定会写。作为一个局外人,你可能只看到几行代码,但提问的人肯定与问题有关并且深谙主题,有时一个提示就会触发他的工作。所以不要认为提问者是愚蠢的!更多:stackoverflow.com/questions/15461611/…
    • “询问的人”并不是 SO 上唯一的问题。还有一些人会跟着,不知道上下文,所以我们给他们解释。除了你试图证明你缺乏解释是合理的,你的链接什么也证明不了。阅读链接答案的 cmets,您将看到相同的 cmets。
    • 我不是在为任何事情辩解,我首先尊重 StackOverflow❤️ 规则,我只是表达我的观点。我完全同意对问题或答案的完整解释。描述得越准确,读者就越能理解。毫无疑问。但我要说的是仅且仅有时, 有些答案很清楚,在这些情况下不需要额外的解释和插入额外的解释不应以狂热的方式强加于人.只会让读者厌烦。
    猜你喜欢
    • 2011-04-08
    • 2013-05-03
    • 1970-01-01
    • 2017-03-03
    • 2015-08-03
    • 2022-10-07
    • 2022-12-27
    • 2021-12-30
    相关资源
    最近更新 更多