fix: maybe if i do it the old way??

This commit is contained in:
əlemi 2024-03-26 21:24:10 +01:00
parent 98cb07b547
commit fc4674ecca
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -111,22 +111,30 @@ async fn deliver(key: &PKey<Private>, to: &str, from: &str, payload: serde_json:
let path = to.replace("https://", "").replace("http://", "").replace(&host, ""); let path = to.replace("https://", "").replace("http://", "").replace(&host, "");
let signature_header = Config::new() // let signature_header = Config::new()
.dont_use_created_field() // .dont_use_created_field()
.require_header("host") // .require_header("host")
.require_header("date") // .require_header("date")
.require_header("digest") // .require_header("digest")
.begin_sign("POST", &path, headers) // .begin_sign("POST", &path, headers)
.unwrap() // .unwrap()
.sign(format!("{from}#main-key"), |to_sign| { // .sign(format!("{from}#main-key"), |to_sign| {
tracing::info!("signing '{to_sign}'"); // tracing::info!("signing '{to_sign}'");
let mut signer = Signer::new(MessageDigest::sha256(), key)?; // let mut signer = Signer::new(MessageDigest::sha256(), key)?;
signer.update(to_sign.as_bytes())?; // signer.update(to_sign.as_bytes())?;
let signature = base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?); // let signature = base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?);
Ok(signature) as Result<_, UpubError> // Ok(signature) as Result<_, UpubError>
}) // })
.unwrap() // .unwrap()
.signature_header(); // .signature_header();
let signature_header = {
let to_sign = format!("(request-target): post {path}\nhost: {host}\ndate: {date}");
tracing::info!("signing '{to_sign}'");
let mut signer = Signer::new(MessageDigest::sha256(), key)?;
signer.update(to_sign.as_bytes())?;
base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?)
};
tracing::info!("signature header: {signature_header}"); tracing::info!("signature header: {signature_header}");