grpc.github.io
grpc.github.io copied to clipboard
Mutual auth example in Node
Would very much like examples on how to do mutual auth on node. Its pretty easily done in Go, but in node, its not at all clear from the docs.
For example, this is what they'd like to do in node. Do we have any examples in node to publish (infact, I'd say we publish in all languages)
cer, err := tls.LoadX509KeyPair("./certs/client.crt", "./certs/client.key") if err != nil { fmt.Printf("Error, could not load key and/or cert files %v\n", err) return }
rootCAs := x509.NewCertPool()
pemData, err := ioutil.ReadFile("./certs/ca.crt")
if err != nil {
fmt.Printf("Error, could not load cert file: %v\n", err)
return
}
rootCAs.AppendCertsFromPEM(pemData)
config := &tls.Config{
Certificates: []tls.Certificate{cer},
RootCAs: rootCAs,
}
creds := credentials.NewTLS(config)
conn, err := grpc.Dial("localhost:9012", grpc.WithTransportCredentials(creds))
@murgatroid99 @LisaFC we should add this after GA
@murgatroid99 , can fix/close this?