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 (

"log"

"net/http"

"github.com/rocketlaunchr/https-go"

) func main() { // Create a simple http hander

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

w.WriteHeader(http.StatusNoContent)

}) // Configure the port

httpServer, _ := https.Server("443", https.GenerateOptions{Host: "thecucumber.app"}) // 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.

Repository: https://github.com/rocketlaunchr/https-go

Docs: https://godoc.org/github.com/rocketlaunchr/https-go