Skip to content

Retain SSL host config customizations when reloading SSL bundles - #51290

Open
scottfrederick wants to merge 1 commit into
spring-projects:4.0.xfrom
scottfrederick:gh-51146-tomcat-customization-reload
Open

Retain SSL host config customizations when reloading SSL bundles#51290
scottfrederick wants to merge 1 commit into
spring-projects:4.0.xfrom
scottfrederick:gh-51146-tomcat-customization-reload

Conversation

@scottfrederick

@scottfrederick scottfrederick commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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 SSLHostConfig for each host name, including one for each SNI server name. When an SSL bundle is updated, a new SSLHostConfig is created and passed to AbstractHttp11Protocol.addSslHostConfig with replace set to true. That call replaces the entry for the host name, so any customization that had been applied to the existing SSLHostConfig (for example, with a TomcatConnectorCustomizer) 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 SSLHostConfig on the connector and modifies it with the reloaded SSL Bundle material instead of creating a new SSLHostConfig.

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 SSLHostConfig set 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 a TomcatConnectorCustomizer that applies a SSLHostConfig configured with trustManagerClassName, truststoreProvider, or truststoreAlgorithm, 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.

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>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants