Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-04 02:18:00 +01:00
Use opportunistic TLS in SMTP connections
If SSL is disabled, the SMTP ClientSecurity of the lettre crate defaults to None, that is, an insecure connection. This is changed to Opportunistic, which uses TLS if available. If TLS is not available, the insecure connection is used (i.e., this change is backward compatible).
Dieser Commit ist enthalten in:
Ursprung
70f3ab8ec3
Commit
5d3b765a23
1 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
10
src/mail.rs
10
src/mail.rs
|
@ -18,21 +18,21 @@ use chrono::NaiveDateTime;
|
||||||
fn mailer() -> SmtpTransport {
|
fn mailer() -> SmtpTransport {
|
||||||
let host = CONFIG.smtp_host().unwrap();
|
let host = CONFIG.smtp_host().unwrap();
|
||||||
|
|
||||||
let client_security = if CONFIG.smtp_ssl() {
|
|
||||||
let tls = TlsConnector::builder()
|
let tls = TlsConnector::builder()
|
||||||
.min_protocol_version(Some(Protocol::Tlsv11))
|
.min_protocol_version(Some(Protocol::Tlsv11))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let params = ClientTlsParameters::new(host.clone(), tls);
|
let tls_params = ClientTlsParameters::new(host.clone(), tls);
|
||||||
|
|
||||||
|
let client_security = if CONFIG.smtp_ssl() {
|
||||||
if CONFIG.smtp_explicit_tls() {
|
if CONFIG.smtp_explicit_tls() {
|
||||||
ClientSecurity::Wrapper(params)
|
ClientSecurity::Wrapper(tls_params)
|
||||||
} else {
|
} else {
|
||||||
ClientSecurity::Required(params)
|
ClientSecurity::Required(tls_params)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ClientSecurity::None
|
ClientSecurity::Opportunistic(tls_params)
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
Laden …
In neuem Issue referenzieren