-
Notifications
You must be signed in to change notification settings - Fork 1.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
Wrong Certificate Selected When Using Multiple Virtual Host Names in Conscrypt #2896
Comments
I tried the branch you suggested, but the behavior is still the same. This is not surprising, as the only difference in this branch is how to decide whether SNI is to be used or not. And in our case, we have two wildcard certificates, so both branches do use SNI. |
I have experienced a similar issue with jetty 9.3.24. I have two java services A and B running on the same server. Services use different certificates issued for the same hostname - and this is where the problem starts from. Service A communicate with service B.
Server A starts successfully, but is not accessible - TLS handshake always fails. Details:
This issue has obvious work around: To fix the issue in code it would be enough to process alias |
I also experienced a similar issue with Jetty 9.4.15.v20190215 (reproduced with 9.4.18.v20190429), on OpenJDK 8 using JSSE (not conscrypt). |
I created a minimal working example that shows our problem here: The problem exists with the Jetty version 9.4.20.v20190813, but only when using Conscrypt. |
@mperktold unfortunately this is a known issue in Conscrypt, in particular google/conscrypt#644. |
I think this is resolved now. I have a single jetty instance configured with two different webapps, each with its own domains and certificate. SNI was failing with Conscrypt 2.2.1 but seems to be working OK now with 2.4.0. |
In our project, we are using an embedded Jetty Server version 9.4.12.v20180830 with Conscrypt for SSL.
We have some custom handlers that we select based on virtual host names, which works fine so far.
However, when we try to use different certificates for those handlers, Jetty (or Conscrypt?) picks one of
them and uses that one for all handlers, so accessing one of the other handlers fails since the certificate
doesn't match the requested URI.
We are not exactly sure why this is the case, but we made some observations which might help finding
the problem.
In
SslContextFactory.customize(SSLParameters)
, Jetty sets anAliasSNIMatcher
as the onlySNIMatcher
.Later, in
SniX509ExtendedKeyManager.chooseEngineServerAlias()
, it tries to extract that matcher fromthe engine using
engine.getSSLParameters().getSNIMatchers()
.But here is the first problem: The Engine doesn't keep the
SSLParameters
instance, but only extractsthe ones it needs, and the SNIMatchers are not among them. When calling
getSSLParameters()
like above,a new
SSLParameters
object is created with the previously extracted parameters. This means althoughwe set SNIMatchers, we do not receive them upon calling the getter.
We tried to fix this by patching the Engine to keep the matchers, but then we found another problem.
After extracting the SNIMatchers, Jetty passes them to another method
chooseServerAlias()
, whichsearches an instance of
AliasSNIMatcher
to access itshost
andx507
. These properties are setwhen
AliasSNIMatchermatches(SNIServerName)
is called, but apparently that never happens, sohost
andx507
arenull
and the method returnsNO_MATCHERS
.In fact, we didn't even find any calls of that method in the source code of either Jetty or Conscrypt,
so we are not sure how this is supposed to work.
Also, as a side note: The JavaDoc of
SNIMatcher
states that instances are immutable. This is apparentlynot the case for
AliasSNIMatcher
, but I guess this is intentional?But back to the problem:
After
chooseServerAlias()
returnsNO_MATCHERS
, the call is delegated to_delegate
, which does notseem to care about multiple aliases and just returns the first one, which explains the behavior we are
experiencing.
In my opinion, there is actually a problem in the way Jetty and Conscrypt are working together to select
the right alias, but the problem could be in our usage of Jetty and virtual hosts as well.
In this regard, we use a custom main handler which selects the actual handler to be called based on the
request URI, including virtual host name information. The actual handler is also a custom handler, but usually
wrapped inside other handlers like
GzipHandler
orSecurityHandler
.In particular, we are not using
ContextHandler
. Could that be the problem?Or could this really be an issue of Jetty or Conscrypt?
The text was updated successfully, but these errors were encountered: