diff --git a/src/server/fetcher.rs b/src/server/fetcher.rs index b1c01c73..69f88dbd 100644 --- a/src/server/fetcher.rs +++ b/src/server/fetcher.rs @@ -46,13 +46,13 @@ impl Fetcher { .header("Date", date.clone()); let mut signature_cfg = Config::new().mastodon_compat(); - let mut to_sign_raw = format!("(request-target): post {path}\nhost: {host}\ndate: {date}"); - let mut headers_to_inspect = "(request-target) host date"; + // let mut to_sign_raw = format!("(request-target): post {path}\nhost: {host}\ndate: {date}"); + // let mut headers_to_inspect = "(request-target) host date"; if let Some(payload) = payload { let digest = format!("sha-256={}", base64::prelude::BASE64_STANDARD.encode(openssl::sha::sha256(payload.as_bytes()))); - to_sign_raw = format!("(request-target): post {path}\nhost: {host}\ndate: {date}\ndigest: {digest}"); - headers_to_inspect = "(request-target) host date digest"; + // to_sign_raw = format!("(request-target): post {path}\nhost: {host}\ndate: {date}\ndigest: {digest}"); + // headers_to_inspect = "(request-target) host date digest"; headers.insert("Digest".to_string(), digest.clone()); signature_cfg = signature_cfg.require_header("digest"); client = client @@ -60,11 +60,11 @@ impl Fetcher { .body(payload.to_string()); } - let signature_header_lib = signature_cfg + let signature_header = signature_cfg .begin_sign("POST", &path, headers) .unwrap() .sign(format!("{from}#main-key"), |to_sign| { - tracing::info!("signature string:\nlib>> {to_sign}\nraw>> {to_sign_raw}"); + // tracing::info!("signature string:\nlib>> {to_sign}\nraw>> {to_sign_raw}"); 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()?); @@ -74,14 +74,14 @@ impl Fetcher { .signature_header() .replace("hs2019", "rsa-sha256"); // TODO what the fuck??? why isn't this customizable??? - let signature_header = { - let mut signer = Signer::new(MessageDigest::sha256(), key).unwrap(); - signer.update(to_sign_raw.as_bytes()).unwrap(); - let signature = base64::prelude::BASE64_STANDARD.encode(signer.sign_to_vec().unwrap()); - format!("keyId=\"{from}#main-key\",algorithm=\"rsa-sha256\",headers=\"{headers_to_inspect}\",signature=\"{signature}\"") - }; + // let signature_header = { + // let mut signer = Signer::new(MessageDigest::sha256(), key).unwrap(); + // signer.update(to_sign_raw.as_bytes()).unwrap(); + // let signature = base64::prelude::BASE64_STANDARD.encode(signer.sign_to_vec().unwrap()); + // format!("keyId=\"{from}#main-key\",algorithm=\"rsa-sha256\",headers=\"{headers_to_inspect}\",signature=\"{signature}\"") + // }; - tracing::info!("signature headers:\nlib>> {signature_header_lib}\nraw>> {signature_header}"); + // tracing::info!("signature headers:\nlib>> {signature_header_lib}\nraw>> {signature_header}"); client .header("Signature", signature_header)