Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 23, 2021 11:41
Show Gist options
  • Save percybolmer/ae1f11288f3e4f6cc5bf6e867783efcc to your computer and use it in GitHub Desktop.
Save percybolmer/ae1f11288f3e4f6cc5bf6e867783efcc to your computer and use it in GitHub Desktop.
Generates a TLS grpc server by reading a Cert and Key
// GenerateTLSApi will load TLS certificates and key and create a grpc server with those.
func GenerateTLSApi(pemPath, keyPath string) (*grpc.Server, error) {
cred, err := credentials.NewServerTLSFromFile(pemPath, keyPath)
if err != nil {
return nil, err
}
s := grpc.NewServer(
grpc.Creds(cred),
)
return s, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment