mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
add let's encrypt certificate missing on some older android devices (#2752)
* add let's encrypt certificate missing on some older android devices * create Certificate with Lazy::new() * document certificate source * use smaller *.der format instead of *.pem
This commit is contained in:
BIN
assets/root-certificates/letsencrypt/isrgrootx1.der
Normal file
BIN
assets/root-certificates/letsencrypt/isrgrootx1.der
Normal file
Binary file not shown.
@@ -11,8 +11,10 @@ use anyhow::Result;
|
|||||||
use async_std::io;
|
use async_std::io;
|
||||||
use async_std::net::TcpStream;
|
use async_std::net::TcpStream;
|
||||||
|
|
||||||
|
use async_native_tls::Certificate;
|
||||||
pub use async_smtp::ServerAddress;
|
pub use async_smtp::ServerAddress;
|
||||||
use fast_socks5::client::Socks5Stream;
|
use fast_socks5::client::Socks5Stream;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Display, FromPrimitive, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Display, FromPrimitive, PartialEq, Eq)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
@@ -368,8 +370,18 @@ fn get_readable_flags(flags: i32) -> String {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this certificate is missing on older android devices (eg. lg with android6 from 2017)
|
||||||
|
// certificate downloaded from https://letsencrypt.org/certificates/
|
||||||
|
static LETSENCRYPT_ROOT: Lazy<Certificate> = Lazy::new(|| {
|
||||||
|
Certificate::from_der(include_bytes!(
|
||||||
|
"../assets/root-certificates/letsencrypt/isrgrootx1.der"
|
||||||
|
))
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
|
||||||
pub fn dc_build_tls(strict_tls: bool) -> async_native_tls::TlsConnector {
|
pub fn dc_build_tls(strict_tls: bool) -> async_native_tls::TlsConnector {
|
||||||
let tls_builder = async_native_tls::TlsConnector::new();
|
let tls_builder =
|
||||||
|
async_native_tls::TlsConnector::new().add_root_certificate(LETSENCRYPT_ROOT.clone());
|
||||||
|
|
||||||
if strict_tls {
|
if strict_tls {
|
||||||
tls_builder
|
tls_builder
|
||||||
@@ -430,4 +442,13 @@ mod tests {
|
|||||||
assert_eq!(param, loaded);
|
assert_eq!(param, loaded);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_build_tls() -> Result<()> {
|
||||||
|
// we are using some additional root certificates.
|
||||||
|
// make sure, they do not break construction of TlsConnector
|
||||||
|
let _ = dc_build_tls(true);
|
||||||
|
let _ = dc_build_tls(false);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user