-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Seeing javax.net.ssl.SSLHandshakeException when enabling Conscrypt #6684
Comments
This seems similar to google/conscrypt#656 . That seems horribly broken in Conscrypt. It is unclear why this wasn't an issue in the past. Which Conscrypt version did you test with? |
It's the default version (2.2.1) from grpc-alts |
This seems to be related with other bug preventing Dataproc from upgrading Conscrypt to 2.2.1. Since google/conscrypt#656 was closed as sort-of work as intended, do we need to add other logic to meet the Conscrypt's requirement? I guess this change was introduced from 2.1 with this PR. |
It is a clear regression. Conscrypt will need to be fixed in some way. |
+@prbprbprb who seems to support Conscrypt currently. May you confirm that this is in fact a Conscrypt bug? |
I'm not sure I'd class it as a bug, but maybe it's a surprising default. :) If you don't set a This behaviour is different to Android where the platform default The "fix" is to set either a default ConscryptHostnameVerifier or HostnameVerifier before making any TLS connections. Note that this is a security-critical component so do not just plug in an allow-all verifier or you are opening yourself up to impersonation attacks. You should be able to use either the okhttp one (although it's Kotlin nowadays) or the AOSP one pretty much unchanged. I think the takeaway here is that on non-Android platforms, Conscrypt should install a better default verifier for fewer surprises all round. I'll file an FR for that. |
Ah, I see @flooey already documented this behaviour in google/conscrypt#665 (I reviewed it and forgot). I think it's feasible to implement a different default in a way that doesn't break Android backward compatibility, but we (Conscrypt) would want to be very careful about setting default security policies on other platforms, because coders never look at this stuff unless it breaks. ;) |
@prbprbprb, it seems a pretty clear bug. Note: I didn't say anything about
HostnameVerifier shouldn't be discussed at all. That is a legacy HTTPSUrlConnection thing. In the design of that legacy API the client (e.g., grpc or HTTPSUrlConnection) had to manually call the API when using SSLSocket or SSLEngine. By default there was no hostname verification. The preferred, modern API is to use Implementing a HostnameVerifier is a pain and, as you mentioned, security-sensitive. Applications should not be writing their own or copying an implementation that must be tracked separately for security enhancements and fixes. |
Also, this is a clear regression, and is meaning gRPC users are unable to upgrade to newer Conscrypt versions. |
I just realized in this issue we aren't using Conscrypt[1]. ReferenceCountedOpenSslEngine is only used with tcnative. It still isn't clear why we see this particular error, but it may be related to #6315
|
From my current observation, probably both Conscrypt's |
Replacing This disables Conscrypt's TrustManager, whose Also, you need to be careful when both Conscrypt and tcnative present. GrpcSslContexts prefers tcnative, so the actual TLS provider being used will be tcnative instead of Conscrypt even though Conscrypt provider is inserted to the first place. @ejona86 |
grpc-alts will use Conscrypt if it is in the classpath and fall back to the system-default provider if Conscrypt is not in the classpath. |
Dataproc (Internal Hadoop) modifies |
What's the requirement for Dataproc's case? |
When Dataproc creates VMs for users, it customizes a bunch of things including Conscrypt configuration and this is not only for gRPC but for all libraries that Hadoop uses such as the GCS HTTP client which can benefit from Conscrypt installed as a default security provider. Since gRPC hasn't went well with Conscrypt 2.1 and later, it's stuck with Conscrypt 1.9. For Dataproc, having a solution where the latest gRPC and Conscrypt work together would be ideal. |
This discussion should be moved to Conscrypt. There is nothing we can do about it in gRPC. One possible fix would be to change the default on OpenJDK, because it is a silly default if it requires configuring the HostNameVerifier. google/conscrypt#834 . Another option is Conscrypt could observe another system property for configuring its default and Dataproc could set that property. One unanswered question is why is Conscrypt 1.9 fine, whereas 2+ broken. It appears that is because google/conscrypt@f32607b was a regression because it "Change to provide the TrustManager by default on OpenJDK." |
Closing. Fixed by #7342. |
What version of gRPC-Java are you using?
1.26.0
What is your environment?
GCE VM ( Debian 4.9.189-3 (2019-09-02))
openjdk version "1.8.0_232"
What did you expect to see?
Enabling Conscrypt should not break gRPC call from a GCE VM (over CFE).
What did you see instead?
Client is running on GCE VM, and after I enabled Conscrypt using "Security.insertProviderAt(Conscrypt.newProvider(), 1)", I saw the following error:
Steps to reproduce the bug
The text was updated successfully, but these errors were encountered: