Skip to content

Commit

Permalink
Fix WebPKIError(UnknownIssuer) when sending with rustls
Browse files Browse the repository at this point in the history
Sending would return Err:
    Io(Custom { kind: InvalidData, error: WebPKIError(UnknownIssuer) })
  • Loading branch information
OJFord committed Feb 14, 2020
1 parent a440ae5 commit c253c52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/smtp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use log::{debug, info};
use native_tls::{Protocol, TlsConnector};
#[cfg(feature = "rustls")]
use rustls::ClientConfig;
#[cfg(feature = "rustls")]
use webpki_roots::TLS_SERVER_ROOTS;
use std::net::{SocketAddr, ToSocketAddrs};
use std::time::Duration;

Expand Down Expand Up @@ -158,7 +160,10 @@ impl SmtpClient {

#[cfg(feature = "rustls")]
pub fn new_simple(domain: &str) -> Result<SmtpClient, Error> {
let tls_parameters = ClientTlsParameters::new(domain.to_string(), ClientConfig::new());
let mut tls = ClientConfig::new();
tls.config.root_store.add_server_trust_anchors(&TLS_SERVER_ROOTS);

let tls_parameters = ClientTlsParameters::new(domain.to_string(), tls);

SmtpClient::new(
(domain, SUBMISSIONS_PORT),
Expand Down

0 comments on commit c253c52

Please sign in to comment.