This article was originally published on bmf-tech.com.
A handy one-liner for when you need a self-signed certificate while writing an HTTP server in Go.
go run $(go env GOROOT)/src/crypto/tls/generate_cert.go -rsa-bits 2048 -host localhost
This will generate cert.pem and key.pem.
I used to rely on openssl or mkcert, but this seems to work well when using Go.
Top comments (0)