Skip to content

SSL host config customizations are lost when reloading SSL bundles - #51290

Merged
philwebb merged 2 commits into
spring-projects:4.0.xfrom
scottfrederick:gh-51146-tomcat-customization-reload
Aug 26, 2026
Merged

philwebb merged 2 commits 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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Aug 6, 2026
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. labels Aug 26, 2026
@philwebb philwebb changed the title Retain SSL host config customizations when reloading SSL bundles SSL host config customizations are lost when reloading SSL bundles Aug 26, 2026
@philwebb philwebb modified the milestones: 4.0.x, 4.0.9 Aug 26, 2026
@philwebb philwebb self-assigned this Aug 26, 2026
scottfrederick and others added 2 commits August 25, 2026 18:52
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.

See spring-projectsgh-51290

Signed-off-by: Scott Frederick <scottyfred@gmail.com>
@philwebb
philwebb force-pushed the gh-51146-tomcat-customization-reload branch from 8aeb269 to fa163d4 Compare August 26, 2026 01:53
@philwebb
philwebb merged commit b41cff1 into spring-projects:4.0.x Aug 26, 2026
3 of 4 checks passed
@philwebb

Copy link
Copy Markdown
Member

Thanks very much @scottfrederick!! Are you able to submit another PR for scottfrederick@7e9e07a now that this one has been merged?

@scottfrederick

Copy link
Copy Markdown
Contributor Author

Sure thing, I'll do that tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants