-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][admin] Add SNI header when tlsHostnameVerification is not enabled #17543
Conversation
@michaeljmarshall PTAL |
/pulsarbot run-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution looks good to me, but it needs one minor fix (see comment).
The underlying issue is here:
public SSLEngine newSslEngine(AsyncHttpClientConfig config, String peerHost, int peerPort) {
SSLEngine sslEngine =
config.isDisableHttpsEndpointIdentificationAlgorithm() ?
sslContext.newEngine(ByteBufAllocator.DEFAULT) :
sslContext.newEngine(ByteBufAllocator.DEFAULT, domain(peerHost), peerPort);
configureSslEngine(sslEngine, config);
return sslEngine;
}
Specifically, when the engine is created without the hostname
, the engine does not have the hostname to then pass as a header, which breaks the SNI routing.
An alternative solution could have overridden the newSslEngine
method, but that seems equivalent to this one, so no need to change this PR.
Additionally, I was concerned that this would affect the case where hostname verification is not enabled and SNI is not used, but I think we should be fine, since this is just a header and we pass these headers when creating the client ssl engines for the Pulsar Protocol connections.
Thanks for opening the PR @fantapsody, I didn't understand the issue originally, but the PR helped me see it.
pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java
Outdated
Show resolved
Hide resolved
I wonder can we use the |
@michaeljmarshall Thanks for the feedback, please take another look. |
@nodece I think they do different validations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @fantapsody!
@fantapsody - can you please rebase this PR so that it picks up the latest CI fixes? There were recent changes that we need to capture before we can merge this PR. Thanks. |
609b666
to
a84e913
Compare
Done. @michaeljmarshall |
…ed (apache#17543) (cherry picked from commit 99b52eb) (cherry picked from commit 5cc6eeb)
Fixes #16416
Motivation
The pulsar admin client and the HTTP lookup service don't add an SNI header when
tlsHostnameVerification
is not enabled.Modifications
The async-http-client doesn't split the flag for SNI header and hostname verification, so I added a new SSL engine factory to set the SNI header.
Verifying this change
This change is already covered by existing tests, such as (please describe tests).
Does this pull request potentially affect one of the following parts:
Documentation
Check the box below or label this PR directly.
Need to update docs?
doc-required
(Your PR needs to update docs and you will update later)
doc-not-needed
(Please explain why)
doc
(Your PR contains doc changes)
doc-complete
(Docs have been already added)