Merge pull request #67 from iamqizhao/master
rename the convenience function to set TLS creds
This commit is contained in:
@ -61,9 +61,9 @@ type dialOptions struct {
|
||||
// credentials.
|
||||
type DialOption func(*dialOptions)
|
||||
|
||||
// WithClientTLS returns a DialOption which configures a TLS credentials
|
||||
// for connection.
|
||||
func WithClientTLS(creds credentials.TransportAuthenticator) DialOption {
|
||||
// WithTransportCredentials returns a DialOption which configures a
|
||||
// connection level security credentials (e.g., TLS/SSL).
|
||||
func WithTransportCredentials(creds credentials.TransportAuthenticator) DialOption {
|
||||
return func(o *dialOptions) {
|
||||
o.authOptions = append(o.authOptions, creds)
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ func main() {
|
||||
} else {
|
||||
creds = credentials.NewClientTLSFromCert(nil, sn)
|
||||
}
|
||||
opts = append(opts, grpc.WithClientTLS(creds))
|
||||
opts = append(opts, grpc.WithTransportCredentials(creds))
|
||||
}
|
||||
conn, err := grpc.Dial(*serverAddr, opts...)
|
||||
if err != nil {
|
||||
|
@ -5,7 +5,7 @@ As outlined <a href="https://github.com/grpc/grpc-common/blob/master/grpc-auth-s
|
||||
# Enabling TLS on a gRPC client
|
||||
|
||||
```Go
|
||||
conn, err := grpc.Dial(serverAddr, grpc.WithClientTLS(credentials.NewClientTLSFromCert(nil, ""))
|
||||
conn, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, ""))
|
||||
```
|
||||
|
||||
# Enableing TLS on a gRPC server
|
||||
|
@ -316,7 +316,7 @@ func main() {
|
||||
} else {
|
||||
creds = credentials.NewClientTLSFromCert(nil, sn)
|
||||
}
|
||||
opts = append(opts, grpc.WithClientTLS(creds))
|
||||
opts = append(opts, grpc.WithTransportCredentials(creds))
|
||||
if *testCase == "compute_engine_creds" {
|
||||
opts = append(opts, grpc.WithPerRPCCredentials(credentials.NewComputeEngine()))
|
||||
} else if *testCase == "service_account_creds" {
|
||||
|
@ -220,7 +220,7 @@ func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, tc testpb.TestService
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create credentials %v", err)
|
||||
}
|
||||
conn, err = grpc.Dial(addr, grpc.WithClientTLS(creds))
|
||||
conn, err = grpc.Dial(addr, grpc.WithTransportCredentials(creds))
|
||||
} else {
|
||||
conn, err = grpc.Dial(addr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user