Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: SNI name with trailing dot (absolute name) fails tls handshake #63117

Open
mjl- opened this issue Sep 20, 2023 · 2 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mjl-
Copy link

mjl- commented Sep 20, 2023

Note: I don't think this is a bug in Go crypto/tls, but its strict handling may cause interoperability issues.

Go version

go1.21.1, probably earlier too.

What did you do?

Start a crypto/tls-based webserver. Browse to it with a popular browser (firefox, chromium, safari) with a URL that has a trailing dot, e.g. https://www.xmox.nl./

What did you expect to see?

You may expect to see a website.

What did you see instead?

A TLS handshake error.

It looks like the popular browsers do not remove the trailing dot from the SNI name used in their TLS handshake. Crypto/tls correctly (according to the TLS RFC) refuses the connection. See https://github.com/golang/go/blob/go1.21.1/src/crypto/tls/handshake_messages.go#L447

For firefox, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1008120
For chromium, see: https://bugs.chromium.org/p/chromium/issues/detail?id=593952

Curl does strip the trailing dot from SNI, so curl https://www.xmox.nl./ can get to the HTTP response (though in this case the domain with trailing dot is not configured).

For most websites I tried to access with an absolute domain name (that are likely not running a crypto/tls-based HTTPS-webserver) the connections do work, e.g.: https://www.google.com./ https://www.amazon.com./

Some more examples that don't work: https://caddyserver.com./, https://nu.nl./ (appears to use skipper).

From memory (about 6 months ago), I first ran into this when using a crypto/tls-based webserver to offer email account autodiscovery to Microsoft Outlook. The incoming autodiscovery HTTPS connections had a trailing dot in the SNI name, so autodiscovery failed. Outlook seems to have made up the absolute URL itself.

To summarize: I don't think this is a bug in crypto/tls, and I like its correct/strict behaviour, but that may cause interoperability issues. I'm mostly filing this bug for future reference and possible discussion and after a hint from @FiloSottile.

@mateusz834
Copy link
Member

Also RFC 5280:

When the subjectAltName extension contains a domain name system
label, the domain name MUST be stored in the dNSName (an IA5String).
The name MUST be in the "preferred name syntax", as specified by
Section 3.5 of [RFC1034] and as modified by Section 2.1 of
[RFC1123].

It does not allow trailing dots.

@thanm thanm added this to the Backlog milestone Sep 25, 2023
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 25, 2023
@thanm
Copy link
Contributor

thanm commented Sep 25, 2023

@FiloSottile @rolandshoemaker @golang/security per owners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants