From 8437de6c1b84153b3e1b3ed9989c5a7269500f43 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 26 Mar 2024 21:48:39 +0100 Subject: [PATCH] fix: add back algorithm, fix digest fn --- src/dispatcher.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 382d9253..3576ed1c 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -99,7 +99,7 @@ async fn worker(db: DatabaseConnection, domain: String, poll_interval: u64) -> R async fn deliver(key: &PKey, to: &str, from: &str, payload: serde_json::Value, domain: &str) -> Result<(), UpubError> { let payload = serde_json::to_string(&payload).unwrap(); - let digest = format!("sha-256={}", sha256::digest(&payload)); + let digest = format!("sha-256={}", base64::prelude::BASE64_URL_SAFE.encode(openssl::sha::sha256(payload.as_bytes()))); let host = Context::server(to); let date = chrono::Utc::now().format("%d %b %Y %H:%M:%S %Z").to_string(); // TODO literally what the fuck let path = to.replace("https://", "").replace("http://", "").replace(&host, ""); @@ -135,7 +135,7 @@ async fn deliver(key: &PKey, to: &str, from: &str, payload: serde_json: let mut signer = Signer::new(MessageDigest::sha256(), key)?; signer.update(to_sign.as_bytes())?; let signature = base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?); - format!("keyId=\"{from}#main-key\",headers=\"host date digest\",signature=\"{signature}\"") + format!("keyId=\"{from}#main-key\",algorithm=\"rsa-sha256\",headers=\"host date digest\",signature=\"{signature}\"") }; tracing::info!("signature header:\n{signature_header}");