-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] core: Allow LoadBalancer2 to use a different authority per SubChannel #2662
Conversation
Add a variant of createSubChannel() to LbHelperImpl. The new method has an additional argument for authority. Background: Square has the following configuration of NameResolver and LoadBalancer. - NameResolver resolves an RPC service name (e.g., ExampleService) to DNS names (e.g., example.datacenter1.squareup.com, example.datacenter2.squareup.com). - LoadBalancer creates a SubChannel per DNS name. Each Subchannel gets its authority from ManagedChannel#authority(), which returns the service authority that the NameResolver uses (= ExampleService). On the other hand, our certificate is not configured to support ExampleService as an SNI. Thus, we got the following error: Updating sub channel state: TRANSIENT_FAILURE(Status{code=UNAVAILABLE,description=null, cause=javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem ... at java.lang.Thread.run(Thread.java:745) Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching ExampleService found. We can of course update our certificates, but it would be nice if we can just use a different authority per subchannel.
We can workaround this, but I can imagine other people having similar issues in the future. @ejona86 @zhangkun83 thoughts? |
|
Hmm, I'm not sure that's doable. The javadoc of |
Yeah. So currently |
@lukaszx0, looks like you are misusing authority. The authority returned by NameResolver is meant to be used directly for making TLS connections. If authority is locally derived by audited code from the target provided by user, we can make sure that the servers we connect to and send RPCs to are authenticated as the identity represented by the target. This is critical for protecting user data. If NameResolver were to derive authority from network, the name resolution must be secure so that the authority is not tampered with on the network. This is a bigger topic than a Java API change, and should involve all other languages. @jboeuf is working on the security aspect of gRPC. He may give a better insight of this issue. |
I see. That makes sense. If this is not a recommended approach, our option would be to just modify certs, I guess. Could you let us if there is any other option? |
What does your target string look like? Using the RPC service name as the authority is unusual. Have you considered using something like |
@zhangkun83 thanks, this makes sense. Currently our secinfra is set up in a way that doesn't support it, but I just talked with some folks and I think we can easily fix/workaround this.
I think we'll continue to use service name as authority with which we'll update our certs to make it work. The targets that we're currently using are what we call cluster specs. So for example for the |
Just my 2 cents here. gRPC is doing the right thing. If the certificate doesn't list the authority, the call should fail.
|
Thanks, everyone! I'll close the PR. (Just to clarify, using |
If your name resolver is not trusted (such as it is the case for unsecure DNS), it is a security issue to change the authority based on it. In my example, if you replace DNS by another untrusted naming system that can return an authority, all the attacker would have to do is to say that the authority for mycatpictures.com is actually mytrustedbank.com and voilà! I asked @zhangkun83 to document the fact that implementations |
Yes, I agreed. Thanks for the detailed explanation! |
Add a variant of
createSubChannel()
toLbHelperImpl
. The new method has an additional argument for authority.Background: Square has the following configuration of NameResolver and LoadBalancer.
ExampleService
) to DNS names (e.g.,example.datacenter1.squareup.com
,example.datacenter2.squareup.com
).SubChannel
per DNS name.Each
Subchannel
gets its authority fromManagedChannel#authority()
, which returns the service authority that the NameResolver uses (=ExampleService
).On the other hand, our certificate is not configured to support
ExampleService
as an SNI. Thus, we got the following error:We can of course update our certificates, but it would be nice if we can just use a different authority per
Subchannel
.