-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Thanks for your blog post, very inspiring. One thing I noticed while trying to implement this on a gRPC client is your example calls NewServerTLSFromCert instead of NewClientTLSFromCert. I personally use client configs for Dial options (I might be off here).
conn, err := grpc.Dial(*serverAddr, grpc.NewServerTLSFromCert(tlsCert))
if err != nil {
...
}
defer conn.Close()So, in my case I had to create a certPool with the PeerCertificates that I can pass to NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string).
certPool := x509.NewCertPool()
for _, cert := range tconn.ConnectionState().PeerCertificates {
certPool.AddCert(cert)
}The good news is that it works!, I could connect to the devices (server) without manually providing the .pem certificate file. On the other hand, I'm still wrapping my head around this as NewClientTLSFromCert pass this cert as RootCAs.
func NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string) TransportCredentials {
return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp})
}Metadata
Metadata
Assignees
Labels
No labels