Always send RSA256-signed requests

This commit is contained in:
Natty 2024-04-29 18:26:39 +02:00
parent e21c5a8132
commit 553dbb9b7b
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 14 additions and 8 deletions

View File

@ -3,16 +3,17 @@ use std::{fmt::Display, sync::Arc};
use chrono::Utc;
use http::{HeaderMap, HeaderName, HeaderValue, Method};
use indexmap::IndexSet;
use magnetar_core::web_model::content_type::ContentActivityStreams;
use serde_json::Value;
use sha2::Digest;
use thiserror::Error;
use url::Url;
use magnetar_core::web_model::content_type::ContentActivityStreams;
use crate::{
client::federation_client::{FederationClient, FederationClientError},
crypto::{ApSigningError, ApSigningKey, SigningAlgorithm},
ApClientService, ApSignature, ApSigningField, ApSigningHeaders, SigningInput, SigningParts,
ApClientService,
ApSignature,
ApSigningField, ApSigningHeaders, client::federation_client::{FederationClient, FederationClientError}, crypto::{ApSigningError, ApSigningKey, SigningAlgorithm}, SigningInput, SigningParts,
};
pub struct ApClientServiceDefaultProvider {
@ -413,9 +414,9 @@ mod test {
use crate::{
ap_client::ApClientServiceDefaultProvider,
ApClientService,
client::federation_client::FederationClient,
crypto::{ApHttpPrivateKey, SigningAlgorithm},
ApClientService,
};
#[tokio::test]
@ -427,7 +428,12 @@ mod test {
let rsa_key = rsa::RsaPrivateKey::from_pkcs8_pem(key.trim()).into_diagnostic()?;
let ap_client = ApClientServiceDefaultProvider {
client: Arc::new(
FederationClient::new(true, 128_000, 25, UserAgent::from_static("magnetar/0.42"))
FederationClient::new(
true,
128_000,
25,
UserAgent::from_static("magnetar/0.42 (https://astolfo.social)"),
)
.into_diagnostic()?,
),
};
@ -435,9 +441,9 @@ mod test {
let val = ap_client
.signed_get(
ApHttpPrivateKey::Rsa(Box::new(Cow::Owned(rsa_key)))
.create_signing_key(&key_id, SigningAlgorithm::Hs2019)
.create_signing_key(&key_id, SigningAlgorithm::RsaSha256)
.into_diagnostic()?,
SigningAlgorithm::Hs2019,
SigningAlgorithm::RsaSha256,
None,
&url,
)