Add Date header so the relay can actually make requests lmao

This commit is contained in:
asonix 2020-04-23 13:36:06 -05:00
parent d3e3a13997
commit 13a968aaa9

View file

@ -1,11 +1,12 @@
use crate::error::MyError; use crate::error::MyError;
use activitystreams::primitives::XsdAnyUri; use activitystreams::primitives::XsdAnyUri;
use actix_web::client::Client; use actix_web::{client::Client, http::header::Date};
use bytes::Bytes; use bytes::Bytes;
use http_signature_normalization_actix::prelude::*; use http_signature_normalization_actix::prelude::*;
use log::{debug, info}; use log::{debug, info};
use rsa::{hash::Hashes, padding::PaddingScheme, RSAPrivateKey}; use rsa::{hash::Hashes, padding::PaddingScheme, RSAPrivateKey};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::time::SystemTime;
#[derive(Clone)] #[derive(Clone)]
pub struct Requests { pub struct Requests {
@ -35,6 +36,7 @@ impl Requests {
.client .client
.get(url) .get(url)
.header("Accept", "application/activity+json") .header("Accept", "application/activity+json")
.set(Date(SystemTime::now().into()))
.signature( .signature(
self.config.clone(), self.config.clone(),
self.key_id.clone(), self.key_id.clone(),
@ -70,6 +72,7 @@ impl Requests {
.client .client
.get(url) .get(url)
.header("Accept", "*/*") .header("Accept", "*/*")
.set(Date(SystemTime::now().into()))
.signature( .signature(
self.config.clone(), self.config.clone(),
self.key_id.clone(), self.key_id.clone(),
@ -124,6 +127,7 @@ impl Requests {
.post(inbox.as_str()) .post(inbox.as_str())
.header("Accept", "application/activity+json") .header("Accept", "application/activity+json")
.header("Content-Type", "application/activity+json") .header("Content-Type", "application/activity+json")
.set(Date(SystemTime::now().into()))
.signature_with_digest( .signature_with_digest(
self.config.clone(), self.config.clone(),
self.key_id.clone(), self.key_id.clone(),