简体   繁体   中英

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 --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?

I tried combining cert.pem and ca.pem in a new file and using that as my --cert file, but that didn't work.

I got it. In HTTPie you just pass the ca.pem using --verify like this

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

Only ca.pem is required. 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.

在此处输入图片说明

One additional option is to leverage HTTPie Configurable options to automatically pass the --verify flag for any http call:

~/.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!

http https://local.dev

Response:

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

...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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