Created
July 9, 2019 13:55
-
-
Save nleiva/37d28ff68d2ddaa105fd1767df68e7a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Client | |
config := &tls.Config{ | |
InsecureSkipVerify: false, | |
} | |
conn, err := grpc.Dial(address, grpc.WithTransportCredentials(credentials.NewTLS(config))) | |
if err != nil { | |
log.Fatalf("did not connect: %v", err) | |
} | |
defer conn.Close() | |
// Server | |
creds, err := credentials.NewServerTLSFromFile("service.pem", "service.key") | |
if err != nil { | |
log.Fatalf("Failed to setup TLS: %v", err) | |
} | |
s := grpc.NewServer(grpc.Creds(creds)) | |
// ... register gRPC services ... | |
if err = s.Serve(lis); err != nil { | |
log.Fatalf("failed to serve: %v", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment