如何禁用cURL SSL证书验证

120

你好,我想在网站上使用API,但我的curl命令出现错误。

我想要禁用SSL证书验证。

curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

你应该展示你的代码。目前这只是一个关于如何运行命令的问题。基于你的代码,社区可能会建议如何使用适当的CA来连接,而不是完全禁用它。你的策略还有很多需要改进的地方。另请参阅世界上最危险的代码:在非浏览器软件中验证SSL证书 - jww
2
curl -k htps://target-site.com - Siwei
1个回答

197

只需在URL之前的某个位置添加-k开关。

免责声明:使用时自行承担风险。

man curl | less +/--insecure

-k,--insecure (TLS) 默认情况下,curl 建立的每个 SSL 连接都会被验证为安全。此选项允许 curl 处理和操作即使服务器连接被认为不安全的情况。

通过确保服务器证书包含正确的名称并成功地在证书存储区中进行验证来验证服务器连接。

有关更多详情,请参阅在线资源: https://curl.haxx.se/docs/sslcerts.html

另请参见 --proxy-insecure 和 --cacert。


运行得非常好,谢谢@Giles - Aditya Goel
2
你使用 man 和 less 命令构建命令的方式非常酷! - Kamaraju Kusumanchi
2
less选项的解释:+表示执行一个命令。/是搜索命令。--insecure是要搜索的文本。 - wisbucky
1
GG :) 做得好!研究得很棒! - Gilles Quénot

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接