mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +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]]
|
[[package]]
|
||||||
name = "async-imap"
|
name = "async-imap"
|
||||||
version = "0.2.0"
|
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 = [
|
dependencies = [
|
||||||
"async-native-tls 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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>>(
|
pub async fn secure<S: AsRef<str>>(
|
||||||
self,
|
self,
|
||||||
_domain: S,
|
domain: S,
|
||||||
_certificate_checks: CertificateChecks,
|
certificate_checks: CertificateChecks,
|
||||||
) -> ImapResult<Client> {
|
) -> ImapResult<Client> {
|
||||||
if self.is_secure {
|
if self.is_secure {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
} else {
|
} else {
|
||||||
unimplemented!()
|
let Client { mut inner, .. } = self;
|
||||||
// let Client { inner, .. } = self;
|
let tls = dc_build_tls(certificate_checks);
|
||||||
// let tls = dc_build_tls(certificate_checks);
|
inner.run_command_and_check_ok("STARTTLS", None).await?;
|
||||||
// let client_sec = inner.secure(domain, tls).await?;
|
|
||||||
|
|
||||||
// Ok(Client {
|
let stream = inner.into_inner();
|
||||||
// is_secure: true,
|
let ssl_stream = tls.connect(domain.as_ref(), stream).await?;
|
||||||
// inner: client_sec,
|
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 TlsStream<TcpStream> {}
|
||||||
impl SessionStream for TcpStream {}
|
impl SessionStream for TcpStream {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user