Skip to content

Instantly share code, notes, and snippets.

@nleiva
Created July 9, 2019 00:19
Show Gist options
  • Save nleiva/1bacba5e00819711c4a391a1655d43de to your computer and use it in GitHub Desktop.
Save nleiva/1bacba5e00819711c4a391a1655d43de to your computer and use it in GitHub Desktop.
// 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