-
Notifications
You must be signed in to change notification settings - Fork 88
(feature) Allow opt-out from native_tls
crate
#140
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
(feature) Allow opt-out from native_tls
crate
#140
Conversation
native_tls
crate
src/error.rs
Outdated
@@ -22,8 +25,10 @@ pub enum Error { | |||
/// An `io::Error` that occurred while trying to read or write to a network stream. | |||
Io(IoError), | |||
/// An error from the `native_tls` library during the TLS handshake. | |||
#[cfg(feature = "default")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is actually pretty problematic, because it makes features non-additive. I think for this to be okay, we'll need rust-lang/rust#44109, which hasn't landed yet. One possible solution would be to add a variant to the end of this enum
like this:
#[doc(hidden)]
__Nonexhaustive,
That prevents people from matching on Error
, and thus makes the features additive again.
I also just saw #123 (comment), and I think |
As for that test, I would re-write it to manually establish the |
Np! Will do tonight
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I'll not super experienced with cargo features, but when writing tests and trying to prepare this PR, I found that compiling with different sets of features results in the compiler type-checking different sets of code. To ensure that both default and no default compiles, I _think_ it is necessary to at least run a cargo check this way.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I see! Ok, so we probably do want the check with --no-default-features in Azure pipelines, but its probably overkill here.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Right! Or rather feature = "tls" as you mentioned earlier
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Love it!
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I'm very happy to make that change, but I don't fully understand the problem. Does the link you shared explain this issue in more depth?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
That makes a ton of sense to me. I'll see how far I can get on this!!
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
So, with regards to Azure Pipelines, the current CI already checks with As for additive features, consider if one crate, A, has: [dependencies]
imap = { version = "...", default-features = false } And another, B, has: [dependencies]
imap = "..." # so with the tls feature If you have a crate C that depends on both A and B, then cargo will only compile imap once with all the features enabled. However, consider if A contained something like: match imap::connect(...) {
Ok(c) => ...,
Err(imap::Error::Io(...)) => ...,
Err(imap::Error::Bad(...)) => ...,
Err(imap::Error::No(...)) => ...,
...
} That compiles just fine if the By adding the proposed hidden variant: #[doc(hidden)]
__Nonexhaustive, Now it'd be pretty clear to whoever wrote crate A that they should never be trying to match on all the variants of |
I see! Okay, got it. |
I'm happy to tackle this! However, I'm seeing what looks like a lot of refactoring work here to nudge the type signatures. In particular the I spent a few minutes trying to think of how to change the |
I think the |
Ah, that's a shame about |
Oh good catch! I wrote this code last night but somehow forgot to push it. |
Establishes conditional compilation for all integration with the native_tls crate in this crate. Since native_tls has been deeply integrated into this crate for a long time, we want to maintain backwards compatibility by making this feature part of the default. For a consumer of this crate to "opt-out", including this in cargo.toml: ``` [dependencies.imap] version = 0.16.0 # Replace this with the correct version default-features = false ``` See the conversation on Github for details on this approach: #123
In order to discourage folks from connecting securely, we're removing the convenience method imap::connect_insecure. Fear not\! For those who manage security in another way (aka a private network or similar measures), it is still possible to connect without TLS by using the imap::Client::new() method. See that method for examples of how to do this.
Also point out the examples/rustlts.rs file for pure Rust TLS goodness
Looks great, thank you! |
Published in |
Unfortunatly, this implies removing support of unsecured IMAP connection due to evolutions of the IMAP library See jonhoo/rust-imap#140
* Updating non-conflicting deps * Updating atom is not so straightforward * reqwests will be hard to migrate * Upgraded IMAP. Unfortunatly, this implies removing support of unsecured IMAP connection due to evolutions of the IMAP library See jonhoo/rust-imap#140 * Migrating reqwest was just a little harder : I had to get the dependency with the correct feature, then use the blocking part everywhere
Ready for review! @jonhoo
Establishes conditional compilation for all integration with the native_tls crate. Since native_tls has been deeply integrated into this crate for a long time, we want to maintain backwards compatibility by making this feature part of the default.
For a consumer of this crate to "opt-out", include this in cargo.toml:
See the conversation for details on this approach:
#123
In order to discourage developers from avoiding TLS, we're also simultaneously removing the
connect_insecure
method. However, it is still possible to use an unsecured TCP connection for an imap session by usingimap::Client::new()
and providing a naked TcpStream.