Skip to content

Bugfix HTTPS SNI and IP Address#139

Merged
weissi merged 7 commits into
swift-server:masterfrom
StrangeDays:bugfix/https-sni-ip
Dec 16, 2019
Merged

Bugfix HTTPS SNI and IP Address#139
weissi merged 7 commits into
swift-server:masterfrom
StrangeDays:bugfix/https-sni-ip

Conversation

@StrangeDays

Copy link
Copy Markdown
Contributor

Motivation:

Solving the SNI Bug

Modifications:

Added an internal extension on String for checking if the hostname is an IP Address -- see the private extension on SNI. Additionally using the IPv4Address and IPv6Address Function from Network above 10.14 as protecting with #availabe.
Adding the test for HTTPS and IP in as hostname

Result:

We get results with an IP as Hostname

Motivation:

Solving the SNI Bug

Modifications:

Added an internal extension on String for checking if the hostname is an IP Address -- see the private extension on SNI. Additionally using the IPv4Address and IPv6Address Function from Network above 10.14 as protecting with #availabe.
Adding the test for HTTPS and IP in as hostname

Result:

We get results with an IP as Hostname
@swift-server-bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

2 similar comments
@swift-server-bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@Lukasa Lukasa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems like a generally good patch! I've left a few notes in the diff if you don't mind.

Comment thread Sources/AsyncHTTPClient/Utils.swift Outdated
Comment thread Sources/AsyncHTTPClient/Utils.swift
Comment thread Sources/AsyncHTTPClient/HTTPClient.swift Outdated
@StrangeDays
StrangeDays requested a review from Lukasa November 29, 2019 21:05
@StrangeDays

Copy link
Copy Markdown
Contributor Author

anyone else want to review ? to fix that bug?

@Lukasa Lukasa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm basically happy with this patch, though it'd be nice if you could fix up the noise in the diff I highlighted.

Comment thread Tests/AsyncHTTPClientTests/HTTPClientTests.swift Outdated
@StrangeDays StrangeDays closed this Dec 8, 2019
@StrangeDays StrangeDays reopened this Dec 8, 2019
@StrangeDays
StrangeDays requested a review from Lukasa December 10, 2019 15:49

@Lukasa Lukasa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still fine with this.

@Lukasa

Lukasa commented Dec 10, 2019

Copy link
Copy Markdown
Collaborator

@artemredkin or @weissi want to take a look here as well?


#else
internal extension String {
var isIPAddress: Bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Lukasa should we add smth like this to NIO? This is unrelated to this PR but we could make a 'good-first-issue'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, I wouldn't object, though we'd be extending a type we don't own so we'd have to prefix the method name, which is kinda gross.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And actually don't we have this already in the form of SocketAddress(ipAddress:port:)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Lukasa ish, need to give a port too. But maybe that's not too bad?

extension String {
    var isIPAddress: Bool {
        return SocketAddress(ipAddress: self, port: 0) != nil
   }
}

?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I suspect it's fine, and the only reason not to use it here is that you do have to heap-allocate for that code.

@weissi weissi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

love it, thank you!

@weissi

weissi commented Dec 11, 2019

Copy link
Copy Markdown
Contributor

@swift-server-bot test this please

@weissi

weissi commented Dec 16, 2019

Copy link
Copy Markdown
Contributor

@swift-server-bot test this please

@weissi weissi added the 🔨 semver/patch No public API change. label Dec 16, 2019
@weissi weissi added this to the 1.1.0 milestone Dec 16, 2019
@weissi

weissi commented Dec 16, 2019

Copy link
Copy Markdown
Contributor

@swift-server-bot test this please

@weissi
weissi merged commit 8f2f7b1 into swift-server:master Dec 16, 2019
weissi pushed a commit that referenced this pull request Dec 19, 2019
Use the UNIX implementation across all platforms to avoid unnecessary
complexity introduced by platform specific implementations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants