Last active
August 23, 2021 11:41
-
-
Save percybolmer/ae1f11288f3e4f6cc5bf6e867783efcc to your computer and use it in GitHub Desktop.
Generates a TLS grpc server by reading a Cert and Key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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