Code from golang.org/src/crypto/tls/generate_cert.go To follow the instructions to create self-signed cert.pem and key.pem, for example, from this directory: go run generate_cert.go -host localhost