Closed wusuoweiman closed 4 years ago
I'm not sure if this is really a gRPC issue. Could you please verify that your cert configuration is valid, by spinning up a regular server process with the server certs, and have the client do a regular net.Dial and then wrap the resulting net.Conn in a tls.Conn, or directly do a tls.Dial and pass in the tls.Config.
This issue is labeled as requiring an update from the reporter, and no update has been received after 7 days. If no update is provided in the next 7 days, this issue will be automatically closed.
grpc : 1.28.0-dev go version : 1.11.2 system: linux x86_64
summary: I try to use grpc SSL/TLS to to authenticate both the server and client 。Unluckily, it doesn't work well.
I catch the packets (1) client hello seems good (2) server hello seems good (3) client sertificate seems wrong, the length is 0. (4) server return "certificate"
Reproduce:
openssl genrsa -out ca.key 1024 openssl req -new -key ca.key -out ca.csr openssl x509 -req -in ca.csr -signkey ca.key -out ca.crt
openssl req -new -key server.key -out server.csr openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in server.csr -out server.crt
openssl req -new -key client.key -out client.csr openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in client.csr -out client.crt
func ClientCredentials(server string) []grpc.DialOption { opts := []grpc.DialOption{} if notls { opts = append(opts, grpc.WithInsecure()) } else { tlsConfig := &tls.Config{} if insecure { tlsConfig.InsecureSkipVerify = true } else { certificates, certPool := LoadCertificates() tlsConfig.ServerName = server tlsConfig.Certificates = certificates tlsConfig.RootCAs = certPool } opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig))) }
}
./gnmi_get -xpath_target xxx -xpath "" -target_addr -alsologtostderr -ca server.crt -cert client.crt -key client.key