简体   繁体   English

如何在 HTTPie 中使用 CA(如 curl 的 --cacert)

[英]How to use a CA (like curl's --cacert) with HTTPie

In curl I can connect with a private key, client cert, and a ca cert like this在 curl 中,我可以像这样使用私钥、客户端证书和 ca 证书进行连接

curl --cert cert.pem --key key.pem --cacert ca.pem https://example.org

I can see the --cert and --cert-key options in HTTPie, but how could I use the --cacert option in HTTPie?我可以在 HTTPie 中看到 --cert 和 --cert-key 选项,但是如何在 HTTPie 中使用 --cacert 选项?

I tried combining cert.pem and ca.pem in a new file and using that as my --cert file, but that didn't work.我尝试将 cert.pem 和 ca.pem 组合在一个新文件中并将其用作我的 --cert 文件,但这不起作用。

I got it.我明白了。 In HTTPie you just pass the ca.pem using --verify like this在 HTTPie 中,您只需像这样使用 --verify 传递 ca.pem

http --cert cert.pem --cert-key key.pem --verify ca.pem http://example.org

Only ca.pem is required.只需要ca.pem This is correct request:这是正确的要求:

http --verify /etc/nginx/ssl/myCA.pem https://local.dev                              

Both ssl_certificate - cert.pem (crt) and ssl_certificate_key - key.pem (key) should be indicated in server settings, sho you do not need attach them in query. ssl_certificate - cert.pem (crt) 和ssl_certificate_key - key.pem (key) 都应该在服务器设置中指明,你不需要在查询中附加它们。

在此处输入图片说明

One additional option is to leverage HTTPie Configurable options to automatically pass the --verify flag for any http call:另一种选择是利用HTTPie Configurable 选项为任何http调用自动传递--verify标志:

~/.config/httpie/config.json ~/.config/httpie/config.json

{
    "default_options": [
        "--verify=/path/to/ssl/custom_ca_bundle.pem"
    ]
}

This way you can continue calling HTTPie without manually passing --verify each time!这样你就可以继续调用HTTPie,而无需每次都手动传递--verify

http https://local.dev

Response:回复:

HTTP/1.1 200 OK
Content-Type: application/json
Server: nginx

...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM