Skip to content

Commit 9066257

Browse files
committed
Remove async-native-tls dependency
1 parent beebfb5 commit 9066257

File tree

4 files changed

+3
-79
lines changed

4 files changed

+3
-79
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- Remove `async-native-tls` dependency. TLS streams should be created by the library users as documented in `lib.rs`. #68
1213
- Do not generate artificial "broken pipe" errors when attempting to send a request
1314
after reaching EOF on the response stream. #73
1415
- Do not attempt to track if the stream is closed or not.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ is-it-maintained-open-issues = { repository = "async-email/async-imap" }
2121
[features]
2222
default = ["runtime-async-std"]
2323

24-
runtime-async-std = ["async-std", "async-native-tls?/runtime-async-std"]
25-
runtime-tokio = ["tokio", "async-native-tls?/runtime-tokio"]
24+
runtime-async-std = ["async-std"]
25+
runtime-tokio = ["tokio"]
2626

2727
[dependencies]
2828
imap-proto = "0.16.1"
@@ -39,7 +39,6 @@ log = "0.4.8"
3939
thiserror = "1.0.9"
4040
async-channel = "1.6.1"
4141

42-
async-native-tls = { version = "0.4", default-features = false, optional = true }
4342
async-std = { version = "1.8.0", default-features = false, features = ["std", "unstable"], optional = true }
4443
tokio = { version = "1", features = ["net", "sync", "time", "io-util"], optional = true }
4544

@@ -48,4 +47,3 @@ tokio = { version = "1", features = ["net", "sync", "time", "io-util"], optional
4847
pretty_assertions = "1.2"
4948
async-std = { version = "1.8.0", features = ["std", "attributes"] }
5049
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
51-

src/client.rs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ use std::ops::{Deref, DerefMut};
44
use std::pin::Pin;
55
use std::str;
66

7-
#[cfg(feature = "async-native-tls")]
8-
use async_native_tls::{TlsConnector, TlsStream};
9-
10-
#[cfg(all(feature = "async-native-tls", feature = "runtime-tokio"))]
11-
use tokio::net::{TcpStream, ToSocketAddrs};
12-
13-
#[cfg(all(feature = "async-native-tls", feature = "runtime-async-std"))]
14-
use async_std::net::{TcpStream, ToSocketAddrs};
15-
167
use async_channel::{self as channel, bounded};
178
#[cfg(feature = "runtime-async-std")]
189
use async_std::io::{Read, Write, WriteExt};
@@ -118,68 +109,6 @@ impl<T: Read + Write + Unpin + fmt::Debug> DerefMut for Session<T> {
118109
}
119110
}
120111

121-
/// Connect to a server using a TLS-encrypted connection.
122-
///
123-
/// The returned [`Client`] is unauthenticated; to access session-related methods (through
124-
/// [`Session`]), use [`Client::login`] or [`Client::authenticate`].
125-
///
126-
/// The domain must be passed in separately from the `TlsConnector` so that the certificate of the
127-
/// IMAP server can be validated.
128-
///
129-
/// # Examples
130-
///
131-
/// ```no_run
132-
/// # fn main() -> async_imap::error::Result<()> {
133-
/// # async_std::task::block_on(async {
134-
///
135-
/// let tls = async_native_tls::TlsConnector::new();
136-
/// let client = async_imap::connect(("imap.example.org", 993), "imap.example.org", tls).await?;
137-
///
138-
/// # Ok(())
139-
/// # }) }
140-
/// ```
141-
#[cfg(feature = "async-native-tls")]
142-
pub async fn connect<A: ToSocketAddrs, S: AsRef<str>>(
143-
addr: A,
144-
domain: S,
145-
ssl_connector: TlsConnector,
146-
) -> Result<Client<TlsStream<TcpStream>>> {
147-
let stream = TcpStream::connect(addr).await?;
148-
let ssl_stream = ssl_connector.connect(domain.as_ref(), stream).await?;
149-
150-
let mut client = Client::new(ssl_stream);
151-
let _greeting = match client.read_response().await {
152-
Some(greeting) => greeting,
153-
None => {
154-
return Err(Error::Bad(
155-
"could not read server Greeting after connect".into(),
156-
));
157-
}
158-
};
159-
160-
Ok(client)
161-
}
162-
163-
impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
164-
/// This will upgrade an IMAP client from using a regular TCP connection to use TLS.
165-
///
166-
/// The domain parameter is required to perform hostname verification.
167-
#[cfg(feature = "async-native-tls")]
168-
pub async fn secure<S: AsRef<str>>(
169-
mut self,
170-
domain: S,
171-
ssl_connector: TlsConnector,
172-
) -> Result<Client<TlsStream<T>>> {
173-
self.run_command_and_check_ok("STARTTLS", None).await?;
174-
let ssl_stream = ssl_connector
175-
.connect(domain.as_ref(), self.conn.stream.into_inner())
176-
.await?;
177-
178-
let client = Client::new(ssl_stream);
179-
Ok(client)
180-
}
181-
}
182-
183112
// As the pattern of returning the unauthenticated `Client` (a.k.a. `self`) back with a login error
184113
// is relatively common, it's abstacted away into a macro here.
185114
//

src/error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ pub enum Error {
3131
/// strings](https://tools.ietf.org/html/rfc3501#section-4.3).
3232
#[error("validate: {0}")]
3333
Validate(#[from] ValidateError),
34-
/// `async_native_tls` error
35-
#[cfg(feature = "async-native-tls")]
36-
#[error("async_native_tls: {0}")]
37-
NativeTlsError(#[from] async_native_tls::Error),
3834
/// Error appending an e-mail.
3935
#[error("could not append mail to mailbox")]
4036
Append,

0 commit comments

Comments
 (0)