Crates.io | cfdkim |
lib.rs | cfdkim |
version | 0.3.0 |
source | src |
created_at | 2022-01-20 20:48:24.310207 |
updated_at | 2023-09-21 10:44:54.650522 |
description | DKIM (RFC6376) implementation |
homepage | |
repository | https://github.com/cloudflare/dkim |
max_upload_size | |
id | 517849 |
size | 89,585 |
DKIM (RFC6376) implementation
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:
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.
Using OpenDKIM:
opendkim-genkey \
--testmode \
--domain=example.com \
--selector=2022 \
--nosubdomains