Skip to content

Commit

Permalink
v0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Dec 1, 2023
1 parent 53904ce commit 09981bc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mail-send 0.4.2
================================
- Bump `webpki-roots` dependency to 0.26

mail-send 0.4.1
================================
- Bump `webpki-roots` dependency to 0.25
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mail-send"
description = "E-mail delivery library with SMTP and DKIM support"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = [ "Stalwart Labs <hello@stalw.art>"]
license = "Apache-2.0 OR MIT"
Expand All @@ -18,13 +18,13 @@ doctest = false
smtp-proto = { version = "0.1", git = "https://github.com/stalwartlabs/smtp-proto" }
mail-auth = { version = "0.3", git = "https://github.com/stalwartlabs/mail-auth", optional = true }
mail-builder = { version = "0.3", git = "https://github.com/stalwartlabs/mail-builder", optional = true }
base64 = "0.20.0"
base64 = "0.21"
rand = { version = "0.8.5", optional = true }
md5 = { version = "0.7.0", optional = true }
tokio = { version = "1.23", features = ["net", "io-util", "time"]}
rustls = { version = "0.21", features = ["tls12", "dangerous_configuration"]}
tokio-rustls = { version = "0.24"}
webpki-roots = { version = "0.25.2"}
webpki-roots = { version = "0.26"}
gethostname = { version = "0.4"}

[dev-dependencies]
Expand Down
12 changes: 7 additions & 5 deletions src/smtp/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use std::{fmt::Display, hash::Hash};

use base64::{engine, Engine};
use smtp_proto::{
response::generate::BitToString, EhloResponse, AUTH_CRAM_MD5, AUTH_DIGEST_MD5, AUTH_LOGIN,
AUTH_OAUTHBEARER, AUTH_PLAIN, AUTH_XOAUTH2,
Expand Down Expand Up @@ -139,14 +140,14 @@ impl<T: AsRef<str> + PartialEq + Eq + Hash> Credentials<T> {
}

pub fn encode(&self, mechanism: u64, challenge: &str) -> crate::Result<String> {
Ok(base64::encode(
Ok(engine::general_purpose::STANDARD.encode(
match (mechanism, self) {
(AUTH_PLAIN, Credentials::Plain { username, secret }) => {
format!("\u{0}{}\u{0}{}", username.as_ref(), secret.as_ref())
}

(AUTH_LOGIN, Credentials::Plain { username, secret }) => {
let challenge = base64::decode(challenge)?;
let challenge = engine::general_purpose::STANDARD.decode(challenge)?;
let username = username.as_ref();
let secret = secret.as_ref();

Expand Down Expand Up @@ -174,7 +175,7 @@ impl<T: AsRef<str> + PartialEq + Eq + Hash> Credentials<T> {
let mut key = None;
let mut in_quote = false;
let mut values = std::collections::HashMap::new();
let challenge = base64::decode(challenge)?;
let challenge = engine::general_purpose::STANDARD.decode(challenge)?;
let challenge_len = challenge.len();
let username = username.as_ref();
let secret = secret.as_ref();
Expand Down Expand Up @@ -239,7 +240,7 @@ impl<T: AsRef<str> + PartialEq + Eq + Hash> Credentials<T> {
use rand::RngCore;
let mut buf = [0u8; 16];
rand::thread_rng().fill_bytes(&mut buf);
base64::encode(buf)
engine::general_purpose::STANDARD.encode(buf)
};

#[cfg(test)]
Expand Down Expand Up @@ -288,7 +289,8 @@ impl<T: AsRef<str> + PartialEq + Eq + Hash> Credentials<T> {
}
}

secret_ipad.extend_from_slice(&base64::decode(challenge)?);
secret_ipad
.extend_from_slice(&engine::general_purpose::STANDARD.decode(challenge)?);
secret_opad.extend_from_slice(&md5::compute(&secret_ipad).0);

format!("{} {:x}", username, md5::compute(&secret_opad))
Expand Down
6 changes: 3 additions & 3 deletions src/smtp/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ pub fn build_tls_connector(allow_invalid_certs: bool) -> TlsConnector {

root_cert_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
ta.subject.as_ref(),
ta.subject_public_key_info.as_ref(),
ta.name_constraints.as_ref().map(|v| v.as_ref()),
)
}));

Expand Down

0 comments on commit 09981bc

Please sign in to comment.