Self Signed HTTPS Servers for Go
Feb 16 · 1 min read

For more than a decade, security experts have been advocating SSL certificates for servers.

For production servers you can use a SSL certificate from a reputable organization like Let’s Encrypt.

For Development (or non-public facing Production) servers, you may want to self-sign your certificates.

I’ve created a package to make it super quick and easy.

package main

import (
func main() {// Create a simple http hander
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Configure the port
httpServer, _ := https.Server("443", https.GenerateOptions{Host: ""})
// Start the server
log.Fatal(httpServer.ListenAndServeTLS("", ""))

Just remember to change the url from http to https. Also configure your http client code/application to allow self-signed certificates otherwise they will spit out an error.

You can also call GenerateKeys() function to create a key once and reuse it.



Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade