curl使用命令行发送https请求

您所在的位置:网站首页 curl命令无响应 curl使用命令行发送https请求

curl使用命令行发送https请求

2023-11-07 11:14| 来源: 网络整理| 查看: 265

当我们使用curl发送https请求时,如下命令就会报错:

curl "https://www.baidu.com"

在这里插入图片描述 错误代码:

curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: https://curl.haxx.se/docs/sslcerts.html

好多网站上给的解决办法是下载CA证书,但是使用C++代码调用libcurl发送https请求,只需要在设置一下这个就可以关闭ssl验证,从而能够发送https请求

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

因此使用curl命令行肯定也可以通过设置跳过ssl验证,我们打开命令行错误提示的那个网页:https://curl.haxx.se/docs/sslcerts.html

在这里插入图片描述 从这里可以找到在命令行中使用curl发送https请求的解决办法,带上这个参数:-k --insecure

curl -k --insecure "https://www.baidu.com"

可以发现能够成功访问http请求了:

在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3