fix(transport/grpc): separate options for creds and certs #1759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For gRPC, this separates the logic for credential dial options (associated with the
WithoutAuthentication
option) from the connection-level encryption dial options (associated with theWithInsecure
option OR usingDialInsecure
). This allows a secure connection to be dialed without credentials.Previously, using
WithoutAuthentication
alone (i.e. withoutWithInsecure
orgrpc.WithTransportCredentials(credentials.NewTLS(nil))
, and while usingDial
) would result in attempting to dial a secure connection but without any credentials or TLS config, resulting in an error. For example, the following code returns an error:This is not correct. It makes it very difficult for users to, for example, read a public GCS object without credentials, but using a secure connection.
This may seem like a weird use case, but the HTTP version of
dial
doesn't control connection-level encryption via theWithoutAuthentication
option - connection certs loaded here while credentials are loaded here.Note: This also refactors the use of
grpc.WithInsecure
, which is no deprecated, to the preferredgrpcinsecure.NewCredentials()
option.