Repository navigation
Enable hostname verification for SSLSocketFactory in setSocketFactory - #2186
Merged
Merged
Conversation
ConnectionFactory#setSocketFactory now enables server hostname
verification when it receives an SSLSocketFactory. This applies to
blocking IO, the default IO layer. useSslProtocol and
setSslContextFactory have enabled verification by default since
5.33.0, but an SSLSocketFactory passed to setSocketFactory did not
get it. TLS connections set up this way checked the server
certificate chain, but not that the certificate matches the broker
host name.
This is a breaking change for applications that pass an
SSLSocketFactory to setSocketFactory and connect to a broker whose
certificate does not match the host name (for example when connecting
by IP address). These applications should use a certificate that
matches the host name. If that is not possible, they can replace the
socket configurator after setting the socket factory:
factory.setSocketFactory(sslContext.getSocketFactory());
factory.setSocketConfigurator(SocketConfigurators.defaultConfigurator());
Other TLS setups are not affected. useTlsWithNoVerification still
disables hostname verification, and NIO behaves as before.
(cherry picked from commit 10737ca)# Conflicts:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ConnectionFactory#setSocketFactory now enables server hostname verification when it receives an SSLSocketFactory. This applies to blocking IO, the default IO layer. useSslProtocol and setSslContextFactory have enabled verification by default since 5.33.0, but an SSLSocketFactory passed to setSocketFactory did not get it. TLS connections set up this way checked the server certificate chain, but not that the certificate matches the broker host name.
This is a breaking change for applications that pass an SSLSocketFactory to setSocketFactory and connect to a broker whose certificate does not match the host name (for example when connecting by IP address). These applications should use a certificate that matches the host name. If that is not possible, they can replace the socket configurator after setting the socket factory:
Other TLS setups are not affected. useTlsWithNoVerification still disables hostname verification, and NIO behaves as before.