Using HTTPie with mkcert

In order to get the development environment on localhost closer to the production environment, I’m using HTTPS on localhost. This helps me with discovering bugs much earlier, which saves a lot of time.

I use the excellent tool mkcert for managing the certificates locally. mkcert is built exactly for this purpose and removes most of the friction.

I regularly use httpie to interact with HTTP servers.

However, httpie doesn’t know about about the certificate authority installed locally by mkcert, so we’ll have to help it a bit.

http --verify="$(mkcert --CAROOT)/rootCA.pem" https://localhost.myapp.org:8443/some/path

Since I don’t want to type that on every invocation, I’ve added it as an alias in .bash_profile.

alias http="http --verify=\"$(mkcert --CAROOT)/rootCA.pem\""

And then I can use httpie as normal

http https://localhost.myapp.org:8443/some/path