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

Fixes #6276 - Support non-standard domains in SNI and X509. (#6296) #6311

Merged
merged 2 commits into from
May 24, 2021

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented May 21, 2021

Improved support for IP addresses in X509 (after #5379).
Introduced SslContextFactory.Client.SniProvider to allow applications to specify the SNI names to send to the server.
Improved logging of SNI processing.
Skip X509 matching over IP addresses when the host does
not look like an IP address, to avoid reverse DNS lookup.

Signed-off-by: Simone Bordet [email protected]
(cherry picked from commit 04df6d4)

Improved support for IP addresses in X509 (after #5379).
Introduced SslContextFactory.Client.SniProvider to allow applications to specify the SNI names to send to the server.
Improved logging of SNI processing.
Skip X509 matching over IP addresses when the host does
not look like an IP address, to avoid reverse DNS lookup.

Signed-off-by: Simone Bordet <[email protected]>
(cherry picked from commit 04df6d4)
@sbordet sbordet requested a review from gregw May 21, 2021 17:14
@sbordet
Copy link
Contributor Author

sbordet commented May 21, 2021

Forward port of #6296.

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I missed this in original PR, but we can do better with the regex's

Comment on lines 199 to 204
// IPv4 is just numbers and dots.
String ipv4RegExp = "[0-9\\.]+";
// IPv6 is hex and colons and possibly brackets.
String ipv6RegExp = "[0-9a-fA-F:\\[\\]]+";
return host.matches(ipv4RegExp) ||
(host.matches(ipv6RegExp) && containsAtLeastTwoColons(host));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this before the port... but shouldn't we precompile these regex's?
Also they can be more precise: IPv4 must start and finish with a digit; IPv6 may have [] only on the outside and must have a : somewhere (which can be done in regex rather than another method). i think this is specially important for ipv6 matching as a-fA-F can spell out words that might be local host names eg "fab"

We may as well go for a complex address regex like https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses, which can be precompiled and will be quick enough to execute... ideally with a single expression rather than two.

Updates after review.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet requested a review from gregw May 24, 2021 11:15
@sbordet sbordet merged commit cfcb2ef into jetty-10.0.x May 24, 2021
@sbordet sbordet deleted the jetty-10.0.x-6276-support-non-standard-domains branch May 24, 2021 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants