How to use SSL with OCSP with GIN Framework in Go

The GIN framework comes up with the SSL middleware autotls which requests the SSL certificate on request basis. However, it lacks the cool feature of OCSP

However, the CertMagic which generates SSL certificate during initializations – so no surprises here and does support OCSP.


app := gin.Default()
...

// Assuming SSL_DOMAIN has csv domains like varunbatra.com,www.varunbatra.com
domains := os.Getenv("SSL_DOMAIN")
domainsMap := strings.Split(domains, ",")
err := certmagic.HTTPS(domainsMap, app)
if err != nil {
	log.Fatal(err)
}

Worth Sharing?

Easy Ngrok with Docker

If you are using localhost as a development platform, you are probably aware of ngrok. You might have installed it in your machine, along with some dependencies. While I have focused on stateless development machine, it is important for me and developers like me to have everything portable. Now I have ngrok portable with a simple alias:

function expose-ngrok() {
  docker run --rm --net=host -e NGROK_PORT="$1" wernight/ngrok
}

Then navigate to localhost:4040 to find the url assigned to you.

Worth Sharing?