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

fix: Return error on non https uri instead of panic #838

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

djc
Copy link
Contributor

@djc djc commented Nov 15, 2021

Motivation

In getting started with tonic, I ran into an issue where issuing a first request with the default features and no explicit TLS configuration set would just result in a H2 GoAway frame without further context. Given that I was providing a https URL to the Endpoint, it seems reasonable that tonic should be able to give me a more meaningful error in this case.

Solution

If the URI scheme is https and the tls feature is disabled, return an error from the connector. If the feature is enabled but there is no TLS config present, also return an error.

@LucioFranco LucioFranco added this to the 0.7 milestone Nov 15, 2021
#[cfg(not(feature = "tls"))]
{
if is_https {
return Err("connecting to HTTPS without TLS enabled".to_owned().into());
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this an actual error type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed unlikely to me that code would be handling this, but I'm happy to change it if you prefer it the other way.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah lets make it a concrete error or error variant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this?

@djc djc force-pushed the no-tls-error branch 2 times, most recently from dcca865 to 18a4fef Compare January 13, 2022 14:47
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM one nit

tonic/src/transport/service/connector.rs Outdated Show resolved Hide resolved
@djc djc force-pushed the no-tls-error branch 2 times, most recently from 747fc87 to f478ecb Compare February 15, 2022 16:45
@LucioFranco LucioFranco changed the title Make it an error to connect to a https URL without TLS fix: Return error on non https uri instead of panic Feb 15, 2022
@LucioFranco LucioFranco merged commit ef6e245 into hyperium:master Feb 15, 2022
roblabla added a commit to JustRustThings/tonic that referenced this pull request Apr 25, 2022
@guswynn
Copy link
Contributor

guswynn commented May 3, 2022

This never panicked for me? The GoAway was definitely really hard to debug when I first was debugging, but this pr prevents me from using tonic 0.7 with a custom connector (connect_with_connector and friends) that uses tls through some other means (in my case, tokio-native-tls). I have shared how I have set this up in the discord, and I would be curious if @LucioFranco's openssl setup still works on 0.7

poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Jul 19, 2022
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Aug 12, 2022
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Nov 2, 2022
Guiguiprim pushed a commit to JustRustThings/tonic that referenced this pull request Jan 24, 2023
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Jul 24, 2023
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Sep 11, 2023
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Sep 25, 2023
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Sep 29, 2023
poliorcetics pushed a commit to JustRustThings/tonic that referenced this pull request Feb 20, 2024
Guiguiprim added a commit to JustRustThings/tonic that referenced this pull request Jul 10, 2024
Guiguiprim added a commit to JustRustThings/tonic that referenced this pull request Jul 11, 2024
Guiguiprim added a commit to JustRustThings/tonic that referenced this pull request Jul 22, 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.

3 participants