10 releases

Uses new Rust 2021

new 0.2.3 Aug 10, 2022
0.2.2 Aug 9, 2022
0.2.0 Jul 21, 2022
0.1.5 Jun 28, 2022
0.1.2 Jan 23, 2022

#25 in Email

Download history 39/week @ 2022-04-24 45/week @ 2022-05-01 63/week @ 2022-05-08 65/week @ 2022-05-15 39/week @ 2022-05-22 25/week @ 2022-05-29 49/week @ 2022-06-05 4/week @ 2022-06-12 18/week @ 2022-06-19 103/week @ 2022-06-26 46/week @ 2022-07-03 78/week @ 2022-07-10 83/week @ 2022-07-17 85/week @ 2022-07-24 124/week @ 2022-07-31 100/week @ 2022-08-07

392 downloads per month
Used in dmarc

MIT license

82KB
2K SLoC

cfdkim

DKIM (RFC6376) implementation

Features

Verifying email signatures

Example:

let res: DKIMResult = cfdkim::verify_email(&logger, &from_domain, &parsed_email).await?;

if let Some(err) = &res.error() {
  error!(logger, "dkim verify fail: {}", err);
}

println!("dkim={}", res.with_detail());

The verify_email arguments are the following:

  • logger: slog::Logger
  • from_domain: &str (RFC5322.From's domain)
  • parsed_email: mailparse::ParsedMail

Signing an email

Example:

let private_key =
    rsa::RsaPrivateKey::read_pkcs1_pem_file(Path::new("./test/keys/2022.private"))?;

let signer = SignerBuilder::new()
    .with_signed_headers(&["From", "Subject"])?
    .with_private_key(private_key)
    .with_selector("2020")
    .with_logger(&logger)
    .with_signing_domain("example.com")
    .build()?;
let signature = signer.sign(&email)?;

println!("{}", signature); // DKIM-Signature: ...

See the SignerBuilder object documentation for more information.

Generate a test DKIM key

Using OpenDKIM:

opendkim-genkey \
    --testmode \
    --domain=example.com \
    --selector=2022 \
    --nosubdomains

Dependencies

~14–21MB
~478K SLoC