1
0
Fork 0
forked from alemi/upub

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 signature_header = Config::new()
.dont_use_created_field()
.require_header("host")
.require_header("date")
.require_header("digest")
.begin_sign("POST", &path, headers)
.unwrap()
.sign(format!("{from}#main-key"), |to_sign| {
// let signature_header = Config::new()
// .dont_use_created_field()
// .require_header("host")
// .require_header("date")
// .require_header("digest")
// .begin_sign("POST", &path, headers)
// .unwrap()
// .sign(format!("{from}#main-key"), |to_sign| {
// tracing::info!("signing '{to_sign}'");
// 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()?);
// Ok(signature) as Result<_, UpubError>
// })
// .unwrap()
// .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())?;
let signature = base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?);
Ok(signature) as Result<_, UpubError>
})
.unwrap()
.signature_header();
base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?)
};
tracing::info!("signature header: {signature_header}");