4

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.

Ahmadster
  • 181
  • 1
  • 6

3 Answers3

14

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
Ahmadster
  • 181
  • 1
  • 6
2

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.

enter image description here

Daniel
  • 7,684
  • 7
  • 52
  • 76
0

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

...
Mike Reid
  • 171
  • 1
  • 7