From c416efdc0d469da98444c2c0b6624cca015d49cc Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 3 Mar 2022 12:46:25 +0100 Subject: [PATCH] Add timeout for sending activities --- crates/apub_lib/src/signatures.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/apub_lib/src/signatures.rs b/crates/apub_lib/src/signatures.rs index 153eb7453..2ee3a144b 100644 --- a/crates/apub_lib/src/signatures.rs +++ b/crates/apub_lib/src/signatures.rs @@ -15,7 +15,7 @@ use reqwest::Response; use reqwest_middleware::ClientWithMiddleware; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; -use std::str::FromStr; +use std::{str::FromStr, time::Duration}; use tracing::debug; use url::Url; @@ -46,6 +46,8 @@ pub async fn sign_and_send( let request = client .post(&inbox_url.to_string()) + // signature is only valid for 10 seconds, so no reason to wait any longer + .timeout(Duration::from_secs(10)) .headers(headers) .signature_with_digest( HTTP_SIG_CONFIG.clone(),