Recently I needed to build a service that would host both an HTTPS REST API and a gRPC service. I was already using Let’s Encrypt certificates for the gRPC service and while it may be technically possible to reuse the same certificates on multiple ports, having a single open port is preferable.
In this post I’ll show you how to configure a Go gRPC client and server using Let’s Encrypt TLS certificates. This ended up being very simple thanks to the autocert package. Note that at this point that package is not stable, so you should vendor it in your code.
Autocert implements the tls.GetCertificate function and requires a directory to cache certificates in to avoid excessive calls to Let’s Encrypt.
package acme // import github.