Should be only one TransportAuthenticator

This commit is contained in:
Menghan Li
2016-06-06 16:35:41 -07:00
parent 6404c49192
commit f0feaea314
3 changed files with 7 additions and 8 deletions

View File

@ -172,7 +172,7 @@ func WithInsecure() DialOption {
// connection level security credentials (e.g., TLS/SSL).
func WithTransportCredentials(auth credentials.TransportAuthenticator) DialOption {
return func(o *dialOptions) {
o.copts.Authenticators = append(o.copts.Authenticators, auth)
o.copts.Authenticator = auth
}
}
@ -369,11 +369,11 @@ func (cc *ClientConn) newAddrConn(addr Address, skipWait bool) error {
ac.events = trace.NewEventLog("grpc.ClientConn", ac.addr.Addr)
}
if !ac.dopts.insecure {
if len(ac.dopts.copts.Authenticators) == 0 {
if ac.dopts.copts.Authenticator == nil {
return errNoTransportSecurity
}
} else {
if len(ac.dopts.copts.Authenticators) > 0 {
if ac.dopts.copts.Authenticator != nil {
return errCredentialsMisuse
}
for _, cd := range ac.dopts.copts.Credentials {