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

Expose danger_connect_async_without_providing_domain_for_certificate_verification_and_server_name_indication #34

Closed
wants to merge 1 commit into from

Conversation

qtbeee
Copy link

@qtbeee qtbeee commented Mar 7, 2018

With the absence of Happy Eyeballs in Rust, I needed a way to disable certificate checking when trying to connect with an IP address instead of a URL.

Copy link
Member

@daniel-abramov daniel-abramov left a comment

Choose a reason for hiding this comment

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

  1. Can you please rebase the changes so that this commit also includes the change from the previous one?
  2. Can the copy-pasting be avoided? It seems like we end up having functions which are almost equal, probably we could have rewritten it in a bit different way, so that the common code is enclosed in a separate function?

Copy link
Member

@daniel-abramov daniel-abramov left a comment

Choose a reason for hiding this comment

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

This commit should probably be the part of the previous one, otherwise the repository is not compilable within a state of the previous commit, am I right? Could you please rebase it?

Copy link
Member

@daniel-abramov daniel-abramov 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 not sure what is meant by 0.4 and 0.5 here. But it seems that this commit fixes the compilation errors from the previous commits. If so, it should be rebased with the changes it fixes.

@daniel-abramov
Copy link
Member

Hi @qtbeee , thanks for your pull request. Sorry for the late response.
I added a couple remarks regarding your changes, other than that it looks ok for me.

cc @agalakhov

@qtbeee
Copy link
Author

qtbeee commented Mar 28, 2018

Hello, I've made the changes you've requested.

Copy link
Member

@daniel-abramov daniel-abramov left a comment

Choose a reason for hiding this comment

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

Hi, there are several things which may be written a bit shorter, also I would like to suggest to avoid the copy-paste from client_async_tls(). The only difference between safe and danger connect here would be passing or not passing the domain name to the wrap_stream() function.

The client_async_tls() should still ensure, that the domain name is supplied to the wrap_stream() function though.

}

// Helper function for reducing duplicate code
fn get_wrapped_stream<S>(socket: S, domain: String, mode: Mode, dangerously: bool)
Copy link
Member

Choose a reason for hiding this comment

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

This function, together with its additional parameter dangerously is actually not required. You could write it a bit simpler, by changing the signature of wrap_stream() a bit. The wrap_stream() function accepts a domain parameter, for the purpose of allowing it to perform a danger connection, you can just change the type of the domain from String to Option<String>, in this case both danger_wrap_stream() and get_wrapped_stream() are not necessary anymore, i.e. the same thing can be rewritten shorten and simplier ;)

Ok(m) => m,
Err(e) => return Box::new(future::err(e.into())),
};
let domain = match request.url.host_str() {
Copy link
Member

Choose a reason for hiding this comment

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

There is a function which already does the same, it's called domain() and it has been used before, what was the reason to not using it?

Ok(domain) => domain,
Err(err) => return Box::new(future::err(err)),
// Make sure we check domain and mode first. URL must be valid.
let mode = match url_mode(&request.url) {
Copy link
Member

Choose a reason for hiding this comment

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

This duplicates the body of client_async_tls().

.and_then(move |socket| client_async_tls(request, socket)))
}
if dangerously {
Box::new(tcp_connect((domain.as_str(), port), handle).map_err(|e| e.into())
Copy link
Member

Choose a reason for hiding this comment

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

This duplicates the body of client_async_tls().

@daniel-abramov
Copy link
Member

This pull request is not valid anymore since native_tls has been changed, also there was no collaboration regarding the things mentioned during the pull request review, so I'm closing this pull request.

Moreover there is another pull request #41 with the re-implementation, it seems to be more up-to-date.

gregates pushed a commit to gregates/tokio-tungstenite that referenced this pull request Feb 24, 2024
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