Retain SSL host config customizations when reloading SSL bundles - #51290
Open
scottfrederick wants to merge 1 commit into
Open
Retain SSL host config customizations when reloading SSL bundles#51290scottfrederick wants to merge 1 commit into
scottfrederick wants to merge 1 commit into
Conversation
Tomcat's SSL configuration is applied to an `SSLHostConfig` for each host name. When an SSL bundle was updated, a new `SSLHostConfig` was created and used to replace the existing one for that host name, discarding any customizations that had been applied to it (for example by a `TomcatConnectorCustomizer`). Reuse the existing `SSLHostConfig` for the host name when one is present, applying the updated bundle to it rather than replacing it. The existing `SSLHostConfigCertificate` is also reused, as adding a second certificate with an undefined type to an `SSLHostConfig` is rejected by Tomcat. Signed-off-by: Scott Frederick <scottyfred@gmail.com>
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.
While prototyping possible solutions to #51146, I happened upon what I think is a bug in the Tomcat configuration when the host is reloaded with an updated SSL Bundle.
Tomcat's SSL configuration is applied to an
SSLHostConfigfor each host name, including one for each SNI server name. When an SSL bundle is updated, a newSSLHostConfigis created and passed toAbstractHttp11Protocol.addSslHostConfigwithreplaceset totrue. That call replaces the entry for the host name, so any customization that had been applied to the existingSSLHostConfig(for example, with aTomcatConnectorCustomizer) was silently discarded when the bundle reloaded.The reproducer for this is in the integration tests added in this PR.
This suggested fix looks for an existing
SSLHostConfigon the connector and modifies it with the reloaded SSL Bundle material instead of creating a newSSLHostConfig.Note that this only fixes a potential bug on the reload path. A similar change could be made to the initial configuration path, which would retain any
SSLHostConfigset on the connector instead of always creating a new one. This would be one possible solution to #51146, as it would allow a user to create aTomcatConnectorCustomizerthat applies aSSLHostConfigconfigured withtrustManagerClassName,truststoreProvider, ortruststoreAlgorithm, and those settings would be retained instead of overwritten by the bundle.Here is a commit that adds the initial configuration change on top of the reload change in this PR: scottfrederick@7e9e07a.