mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-28 03:17:32 +00:00
refactor: Move sign_ssk into server_keys service
This commit is contained in:
1 parent
4692bd3372
commit
5e971aef3c
2 files changed
+84
-99
No files matched your search
@@ -14,7 +14,7 @@ use std::{
|
||||
use assign::assign;
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
Result, Server, SyncRwLock,
|
||||
Result, Server, SyncRwLock, debug_info,
|
||||
utils::{IterStream, ReadyExt, stream::TryIgnore, timepoint_from_now, to_canonical_object},
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
@@ -304,4 +304,29 @@ impl Service {
|
||||
|
||||
old_keys
|
||||
}
|
||||
|
||||
/// Canonicalize and sign another server's signing keys.
|
||||
pub fn self_sign_signing_keys(
|
||||
&self,
|
||||
remote_server: &ServerName,
|
||||
remote_keys: &Raw<ServerSigningKeys>,
|
||||
) -> Result<Raw<ServerSigningKeys>> {
|
||||
let this_server = self.services.globals.server_name();
|
||||
|
||||
let mut canonical = to_canonical_object(remote_keys)?;
|
||||
|
||||
if remote_server == this_server {
|
||||
debug_info!(
|
||||
%remote_server,
|
||||
object=?remote_keys,
|
||||
"Refusing to sign our own signing keys response (should already be signed)"
|
||||
);
|
||||
} else {
|
||||
self.sign_json(&mut canonical)?;
|
||||
|
||||
strip_extraneous_signatures(&mut canonical, remote_server, &[this_server]);
|
||||
}
|
||||
|
||||
Ok(Raw::<ServerSigningKeys>::from_json(to_raw_value(&canonical)?))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user