Created
July 9, 2019 00:19
-
-
Save nleiva/1bacba5e00819711c4a391a1655d43de 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: true, | |
} | |
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