【问题标题】:cURL vs Postman, different responses to HTTPS POSTcURL vs Postman,对 HTTPS POST 的不同响应
【发布时间】:2020-10-23 10:05:15
【问题描述】:

我们正在为客户端设置报告提要,并且在测试端点时,我们在 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 curl postman tls1.2


    【解决方案1】:

    目标服务器的 SSL 证书似乎已过期。邮递员没有引发错误的原因可能是因为禁用了 SSL 验证检查。

    您可以使用 --insecure-k 选项禁用 curl 中的这些检查。 例如:

    curl https://expired.badssl.com
    

    会抛出与您看到的相同的错误。 与

    curl --insecure https://expired.badssl.com
    

    将返回一个 html 响应正文。

    【讨论】:

    • 我知道使用 cURL 我可以避免不安全的约束。我的兴趣在于如何在 Postman 中复制相同的结果。原因有两个:1) 确保我的工具集可靠且可互换,以及 2) 确保我的论点(支持或反对行动)比“工具 A 有问题,而不管工具 B ”。 Postman 可以选择忽略不安全的服务器。它已关闭。所以,这可能是一个错误。或者它表示其他设置,例如合格标志。
    猜你喜欢
    • 1970-01-01
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多