mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
implement imape secure upgrade
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -93,7 +93,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "async-imap"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/async-email/async-imap?branch=feat/send#be7b9cace12d0f323ef1e6e0a9fc698f4e26b64d"
|
||||
source = "git+https://github.com/async-email/async-imap?branch=feat/send#94a48158d6cc622aa0ed99d10b84088e9e53eb2f"
|
||||
dependencies = [
|
||||
"async-native-tls 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"async-std 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
||||
@@ -120,21 +120,24 @@ impl Client {
|
||||
|
||||
pub async fn secure<S: AsRef<str>>(
|
||||
self,
|
||||
_domain: S,
|
||||
_certificate_checks: CertificateChecks,
|
||||
domain: S,
|
||||
certificate_checks: CertificateChecks,
|
||||
) -> ImapResult<Client> {
|
||||
if self.is_secure {
|
||||
Ok(self)
|
||||
} else {
|
||||
unimplemented!()
|
||||
// let Client { inner, .. } = self;
|
||||
// let tls = dc_build_tls(certificate_checks);
|
||||
// let client_sec = inner.secure(domain, tls).await?;
|
||||
let Client { mut inner, .. } = self;
|
||||
let tls = dc_build_tls(certificate_checks);
|
||||
inner.run_command_and_check_ok("STARTTLS", None).await?;
|
||||
|
||||
// Ok(Client {
|
||||
// is_secure: true,
|
||||
// inner: client_sec,
|
||||
// })
|
||||
let stream = inner.into_inner();
|
||||
let ssl_stream = tls.connect(domain.as_ref(), stream).await?;
|
||||
let boxed: Box<dyn SessionStream> = Box::new(ssl_stream);
|
||||
|
||||
Ok(Client {
|
||||
is_secure: true,
|
||||
inner: ImapClient::new(boxed),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ pub(crate) trait SessionStream:
|
||||
{
|
||||
}
|
||||
|
||||
impl SessionStream for TlsStream<Box<dyn SessionStream>> {}
|
||||
impl SessionStream for TlsStream<TcpStream> {}
|
||||
impl SessionStream for TcpStream {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user