I use mkcert[2] for this but it's still fiddly.
[1] https://letsencrypt.org/docs/certificates-for-localhost/
[2] https://github.com/FiloSottile/mkcert