comment gateway-tls gateway creds

This commit is contained in:
finlab 2021-01-17 22:15:20 +08:00
parent 1a36d08a46
commit c56f6c1c12

View File

@ -54,29 +54,29 @@ func main() {
}
}
func gwCreds() credentials.TransportCredentials {
cert, err := tls.LoadX509KeyPair("./cert/server.pem", "./cert/server.key")
if err != nil {
log.Fatal(err)
}
// func gwCreds() credentials.TransportCredentials {
// cert, err := tls.LoadX509KeyPair("./cert/server.pem", "./cert/server.key")
// if err != nil {
// log.Fatal(err)
// }
certPool := x509.NewCertPool()
ca, err := ioutil.ReadFile("./cert/ca.pem")
if err != nil {
log.Fatal(err)
}
if ok := certPool.AppendCertsFromPEM(ca); !ok {
log.Fatal("failed to append certs")
}
// certPool := x509.NewCertPool()
// ca, err := ioutil.ReadFile("./cert/ca.pem")
// if err != nil {
// log.Fatal(err)
// }
// if ok := certPool.AppendCertsFromPEM(ca); !ok {
// log.Fatal("failed to append certs")
// }
creds := credentials.NewTLS(&tls.Config{
Certificates: []tls.Certificate{cert},
ClientAuth: tls.RequireAndVerifyClientCert, // NOTE: this is optional!
ClientCAs: certPool,
})
// creds := credentials.NewTLS(&tls.Config{
// Certificates: []tls.Certificate{cert},
// ClientAuth: tls.RequireAndVerifyClientCert, // NOTE: this is optional!
// ClientCAs: certPool,
// })
return creds
}
// return creds
// }
func grpcServerClientCreds() grpc.DialOption {
cert, err := tls.LoadX509KeyPair("./cert/client.pem", "./cert/client.key")