Skip to content

Conversation

@YoEight
Copy link

@YoEight YoEight commented Feb 3, 2020

Motivation

Currently, if you want to disable server certificate validation, you have to manually set a rustls configuration. Unfortunately, it also overrides default tonic configuration like ALPN protocols.

Solution

This PR exposes danger_accept_invalid_certs in ClientTlsConfig. That function while still preserving tonic default tls configuration, disables server certificate validation. Because it introduces a security vulnerability, we gated that function behind tls-dangerous feature flag.

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.

This looks like a great start! I left you some comments in line, let me know if you have any questions :)

]
tls = ["transport", "tokio-rustls"]
tls-roots = ["tls", "rustls-native-certs"]
tls-dangerous = ["rustls", "webpki"]
Copy link
Member

Choose a reason for hiding this comment

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

This should only have to enable "rustls/dangerous_configuration" then we leave it out of the default. So this is an opt-in feature that will only enable that specific rustls feature if you opt in.

Copy link
Author

Choose a reason for hiding this comment

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

I didn't know feature flags were transitive, I'm looking into it.

Copy link
Author

Choose a reason for hiding this comment

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

After thinking about it, I don't understand what you want me to do

Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to set tls-dangerous to be like:

tls-dangerous = ["rustls/dangerous-config", "webpki"]

Since, rustls is already included with tokio-rustls this feature set should work.

Let me know if that makes sense!

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.

Looking good! Left a few questions :)

@LucioFranco
Copy link
Member

I am going to close this for now since its a bit old now and if we can avoid having to expose something like this then I think that is better since it is dangerous :D lmk if you have anyquestions.

@fishrockz
Copy link

fishrockz commented Apr 5, 2022

@LucioFranco is there now a nice way to turn off the check? some times when debugging its handy to turn it off and i would like to give my app a cli flag to accept invalid certs

Im happy to open a issue if not but thought i would skip the issue if we can already do this?

@LucioFranco
Copy link
Member

I would suggest for now to go around the transport module and use hyper-rustls + hyper directly.

@YoEight
Copy link
Author

YoEight commented Apr 6, 2022

@LucioFranco could you elaborate on this, specifically in the light of 0.7? Thanks for your time.

@LucioFranco
Copy link
Member

#968 here is a PR that adds an example for this.

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