validateTransportCredentials performs a series of checks on the configured transport credentials. It returns a non-nil error if any of these conditions are met: - no transport creds and no creds bundle is configured - both transport creds and creds bundle are configured - creds bundle is configured,
()
| 480 | // If none of the above conditions are met, the configured credentials are |
| 481 | // deemed valid and a nil error is returned. |
| 482 | func (cc *ClientConn) validateTransportCredentials() error { |
| 483 | if cc.dopts.copts.TransportCredentials == nil && cc.dopts.copts.CredsBundle == nil { |
| 484 | return errNoTransportSecurity |
| 485 | } |
| 486 | if cc.dopts.copts.TransportCredentials != nil && cc.dopts.copts.CredsBundle != nil { |
| 487 | return errTransportCredsAndBundle |
| 488 | } |
| 489 | if cc.dopts.copts.CredsBundle != nil && cc.dopts.copts.CredsBundle.TransportCredentials() == nil { |
| 490 | return errNoTransportCredsInBundle |
| 491 | } |
| 492 | transportCreds := cc.dopts.copts.TransportCredentials |
| 493 | if transportCreds == nil { |
| 494 | transportCreds = cc.dopts.copts.CredsBundle.TransportCredentials() |
| 495 | } |
| 496 | if transportCreds.Info().SecurityProtocol == "insecure" { |
| 497 | for _, cd := range cc.dopts.copts.PerRPCCredentials { |
| 498 | if cd.RequireTransportSecurity() { |
| 499 | return errTransportCredentialsMissing |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | return nil |
| 504 | } |
| 505 | |
| 506 | // channelzRegistration registers the newly created ClientConn with channelz and |
| 507 | // stores the returned identifier in `cc.channelz`. A channelz trace event is |
no test coverage detected