Always send RSA256-signed requests
This commit is contained in:
parent
e21c5a8132
commit
553dbb9b7b
|
@ -3,16 +3,17 @@ use std::{fmt::Display, sync::Arc};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use http::{HeaderMap, HeaderName, HeaderValue, Method};
|
use http::{HeaderMap, HeaderName, HeaderValue, Method};
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use magnetar_core::web_model::content_type::ContentActivityStreams;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use magnetar_core::web_model::content_type::ContentActivityStreams;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::federation_client::{FederationClient, FederationClientError},
|
ApClientService,
|
||||||
crypto::{ApSigningError, ApSigningKey, SigningAlgorithm},
|
ApSignature,
|
||||||
ApClientService, ApSignature, ApSigningField, ApSigningHeaders, SigningInput, SigningParts,
|
ApSigningField, ApSigningHeaders, client::federation_client::{FederationClient, FederationClientError}, crypto::{ApSigningError, ApSigningKey, SigningAlgorithm}, SigningInput, SigningParts,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ApClientServiceDefaultProvider {
|
pub struct ApClientServiceDefaultProvider {
|
||||||
|
@ -413,9 +414,9 @@ mod test {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ap_client::ApClientServiceDefaultProvider,
|
ap_client::ApClientServiceDefaultProvider,
|
||||||
|
ApClientService,
|
||||||
client::federation_client::FederationClient,
|
client::federation_client::FederationClient,
|
||||||
crypto::{ApHttpPrivateKey, SigningAlgorithm},
|
crypto::{ApHttpPrivateKey, SigningAlgorithm},
|
||||||
ApClientService,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -427,7 +428,12 @@ mod test {
|
||||||
let rsa_key = rsa::RsaPrivateKey::from_pkcs8_pem(key.trim()).into_diagnostic()?;
|
let rsa_key = rsa::RsaPrivateKey::from_pkcs8_pem(key.trim()).into_diagnostic()?;
|
||||||
let ap_client = ApClientServiceDefaultProvider {
|
let ap_client = ApClientServiceDefaultProvider {
|
||||||
client: Arc::new(
|
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()?,
|
.into_diagnostic()?,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -435,9 +441,9 @@ mod test {
|
||||||
let val = ap_client
|
let val = ap_client
|
||||||
.signed_get(
|
.signed_get(
|
||||||
ApHttpPrivateKey::Rsa(Box::new(Cow::Owned(rsa_key)))
|
ApHttpPrivateKey::Rsa(Box::new(Cow::Owned(rsa_key)))
|
||||||
.create_signing_key(&key_id, SigningAlgorithm::Hs2019)
|
.create_signing_key(&key_id, SigningAlgorithm::RsaSha256)
|
||||||
.into_diagnostic()?,
|
.into_diagnostic()?,
|
||||||
SigningAlgorithm::Hs2019,
|
SigningAlgorithm::RsaSha256,
|
||||||
None,
|
None,
|
||||||
&url,
|
&url,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue