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

Bugfix HTTPS SNI and IP Address #139

Merged
merged 7 commits into from
Dec 16, 2019

Conversation

StrangeDays
Copy link
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

Can one of the admins verify this patch?

2 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

Copy link
Collaborator

@Lukasa Lukasa left a comment

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.

Sources/AsyncHTTPClient/Utils.swift Outdated Show resolved Hide resolved
Sources/AsyncHTTPClient/Utils.swift Show resolved Hide resolved
Sources/AsyncHTTPClient/HTTPClient.swift Outdated Show resolved Hide resolved
@StrangeDays
Copy link
Contributor Author

anyone else want to review ? to fix that bug?

Copy link
Collaborator

@Lukasa Lukasa left a comment

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.

Tests/AsyncHTTPClientTests/HTTPClientTests.swift Outdated Show resolved Hide resolved
Copy link
Collaborator

@Lukasa Lukasa left a comment

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
Copy link
Collaborator

Lukasa commented Dec 10, 2019

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


#else
internal extension String {
var isIPAddress: Bool {
Copy link
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
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
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
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
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.

Copy link
Contributor

@weissi weissi left a comment

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
Copy link
Contributor

weissi commented Dec 11, 2019

@swift-server-bot test this please

@weissi
Copy link
Contributor

weissi commented Dec 16, 2019

@swift-server-bot test this please

@weissi weissi added the semver/patch For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Dec 16, 2019
@weissi weissi added this to the 1.1.0 milestone Dec 16, 2019
@weissi
Copy link
Contributor

weissi commented Dec 16, 2019

@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 For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants