Skip to content

Server name SSL bundles with upper-case server names are not used with Netty - #52289

Merged
snicoll merged 2 commits into
spring-projects:4.0.xfrom
challa:gh-netty-sni-host-names
Oct 22, 2026
Merged

snicoll merged 2 commits into
spring-projects:4.0.xfrom
challa:gh-netty-sni-host-names

Conversation

@challa

@challa challa commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

With the Netty web server, an entry in server.ssl.server-name-bundles whose server-name contains an upper-case letter is never used. Netty lowercases the SNI host name sent by the client, and the lookup in SslServerCustomizer compares it case-sensitively with the configured name, so server-name: "Api.Example.com" never matches. The handshake then uses the default bundle instead of the configured bundle. If the default certificate does not cover the requested host name, clients performing host name verification reject the connection. Host names are case-insensitive, and Tomcat matches them regardless of case.

A wildcard server-name such as *.example.com is not matched with Netty either. Tomcat supports wildcards, and so do Reactor Netty's own SNI mappings, but Spring Boot's lookup only does exact matches.

To reproduce, configure a default bundle plus server-name: "Api.Example.com" (or "*.example.com") with another bundle, and connect with SNI api.example.com. Tomcat presents the mapped certificate and Netty presents the default one.

This change makes the lookup case-insensitive and falls back to * followed by everything from the first dot, which is the rule Tomcat uses. *.example.com therefore matches api.example.com but not example.com or a.b.example.com. The two new tests fail without the change. If you'd rather treat wildcard matching as an enhancement, I can split it out.

I used an AI coding assistant for parts of the analysis; I reviewed and verified the change and tests myself.

challa added a commit to challa/spring-boot that referenced this pull request Oct 19, 2026
SslServerCustomizer looked up the SSL provider for an SNI host name
with an exact, case-sensitive match. Netty lowercases the SNI host
name, so a configured server name containing an upper-case letter was
never matched and the default bundle was used instead. A wildcard
server name such as "*.example.com" was never matched either.

This commit makes the lookup case-insensitive and falls back to a
wildcard for the first label, as Tomcat does.

See spring-projectsgh-52289

Signed-off-by: Challa Srinivasa Reddy <challa.srinivasareddy@gmail.com>
@challa
challa force-pushed the gh-netty-sni-host-names branch from d20ea41 to ae0a4db Compare October 19, 2026 03:23
@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 Oct 19, 2026
@snicoll snicoll self-assigned this Oct 22, 2026
@snicoll snicoll changed the title Server name SSL bundles with upper-case or wildcard server names are not used with Netty Server name SSL bundles with upper-case server names are not used with Netty Oct 22, 2026
SslServerCustomizer looked up the SSL provider for an SNI host name
with an exact, case-sensitive match. Netty lowercases the SNI host
name, so a configured server name containing an upper-case letter was
never matched and the default bundle was used instead.

See spring-projectsgh-52289

Signed-off-by: Challa Srinivasa Reddy <challa.srinivasareddy@gmail.com>
@snicoll
snicoll force-pushed the gh-netty-sni-host-names branch from ae0a4db to 7f200bc Compare October 22, 2026 14:30
snicoll added a commit to challa/spring-boot that referenced this pull request Oct 22, 2026
Restrict the change to matching server names case-insensitively, and
apply it to RSocket as well, which has its own copy of the lookup.
Server names are normalized when they are registered or updated, and
when they are looked up.

See spring-projectsgh-52289
snicoll added a commit to challa/spring-boot that referenced this pull request Oct 22, 2026
Remove the wildcard matching, and apply the case-insensitive lookup to
RSocket as well, which has its own copy of it. The server name
providers are held in a case-insensitive map so that the lookup, the
registration and the update of a server name all match
case-insensitively.

See spring-projectsgh-52289

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@snicoll
snicoll force-pushed the gh-netty-sni-host-names branch from 7f200bc to efafca7 Compare October 22, 2026 14:59
Remove the wildcard matching, and apply the case-insensitive lookup to
RSocket as well, which has its own copy of it. The server name
providers are held in a case-insensitive map so that the lookup, the
registration and the update of a server name all match
case-insensitively.

See spring-projectsgh-52289
@snicoll
snicoll force-pushed the gh-netty-sni-host-names branch from efafca7 to 45229d4 Compare October 22, 2026 14:59
@snicoll snicoll 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 Oct 22, 2026
@snicoll snicoll added this to the 4.0.10 milestone Oct 22, 2026
@snicoll
snicoll merged commit 9746dc3 into spring-projects:4.0.x Oct 22, 2026
1 of 2 checks passed
@snicoll

snicoll commented Oct 22, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, I stripped the enhancement for wildcards and polished the proposal.

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