我们正在为客户端设置报告源,并且在测试端点时,我们在 cURL(命令行)和 Postman 之间收到不同的响应。在 Postman 中,请求顺利通过;我们得到了 200-OK 的回复。但是,当我们在 cURL 中发送请求时,我们会收到以下响应
curl: (60) SSL certificate problem: certificate has expired
cURL 请求如下所示:
curl -i -H "content-type: application/json" -d '{"foo": [],"bar": [],"baz": []}' https://test.example.com/notARealEndpoint
Postman 设置很难显示,但它的代码转换如下:
cURL解释
curl --location --request POST 'https://test.example.com/not/aReal/Endpoint' --header 'Content-Type: application/json' --header 'Content-Type: text/plain' --data-raw '{"foo": [],"bar": [],"baz": []}'
*顺便说一下,在命令行中运行时会返回相同的
certificate has expired
错误
HTTP解释
POST /not/aReal/Endpoint HTTP/1.1
Host: test.example.com
Content-Type: application/json
Content-Type: text/plain
{"foo": [],"bar": [],"baz": []}
目标服务器的 SSL 证书似乎已过期。邮递员没有引发错误的原因可能是因为禁用了 SSL 验证检查。
您可以使用
--insecure
或 -k
选项禁用curl 中的这些检查。
例如:
curl https://expired.badssl.com
会抛出与您所看到的相同的错误。 与
curl --insecure https://expired.badssl.com
将返回 html 响应正文。