Unversioned archiving

This commit is contained in:
mdecimus
2025-05-15 13:35:40 +02:00
parent 839b7189fa
commit 365c87af20
28 changed files with 360 additions and 219 deletions

View File

@@ -801,12 +801,13 @@ impl MessageStoreCache {
if is_unique_hash {
hash
} else {
loop {
for _ in 0..u32::MAX {
hash = hash.wrapping_add(1);
if !threads_ids.contains(hash) {
return hash;
}
}
hash
}
}
}

View File

@@ -1,7 +1,10 @@
// Adapted from rustls-acme (https://github.com/FlorianUekermann/rustls-acme), licensed under MIT/Apache-2.0.
use std::time::Duration;
use super::AcmeProvider;
use super::jose::{
Body, eab_sign, key_authorization, key_authorization_sha256, key_authorization_sha256_base64,
sign,
};
use base64::Engine;
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
use hyper::header::USER_AGENT;
@@ -11,17 +14,12 @@ use reqwest::{Method, Response};
use ring::rand::SystemRandom;
use ring::signature::{ECDSA_P256_SHA256_FIXED_SIGNING, EcdsaKeyPair, EcdsaSigningAlgorithm};
use serde::Deserialize;
use store::write::Archiver;
use store::{SERIALIZE_CERT_V1, Serialize, SerializedVersion};
use std::time::Duration;
use store::Serialize;
use store::write::UnversionedArchiver;
use trc::AddContext;
use trc::event::conv::AssertSuccess;
use super::AcmeProvider;
use super::jose::{
Body, eab_sign, key_authorization, key_authorization_sha256, key_authorization_sha256_base64,
sign,
};
pub const LETS_ENCRYPT_STAGING_DIRECTORY: &str =
"https://acme-staging-v02.api.letsencrypt.org/directory";
pub const LETS_ENCRYPT_PRODUCTION_DIRECTORY: &str =
@@ -190,7 +188,7 @@ impl Account {
.reason(err)
})?;
Archiver::new(SerializedCert {
UnversionedArchiver::new(SerializedCert {
certificate: cert.serialize_der().map_err(|err| {
trc::EventType::Acme(trc::AcmeEvent::Error)
.caused_by(trc::location!())
@@ -210,12 +208,6 @@ pub struct SerializedCert {
pub private_key: Vec<u8>,
}
impl SerializedVersion for SerializedCert {
fn serialize_version() -> u8 {
SERIALIZE_CERT_V1
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Directory {

View File

@@ -4,8 +4,11 @@
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use std::sync::Arc;
use super::{
AcmeProvider, StaticResolver,
directory::{ACME_TLS_ALPN_NAME, SerializedCert},
};
use crate::{KV_ACME, Server};
use rustls::{
ServerConfig,
crypto::ring::sign::any_ecdsa_type,
@@ -13,19 +16,13 @@ use rustls::{
sign::CertifiedKey,
};
use rustls_pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
use std::sync::Arc;
use store::{
dispatch::lookup::KeyValue,
write::{AlignedBytes, Archive},
write::{AlignedBytes, UnversionedArchive},
};
use trc::AcmeEvent;
use crate::{KV_ACME, Server};
use super::{
AcmeProvider, StaticResolver,
directory::{ACME_TLS_ALPN_NAME, SerializedCert},
};
impl Server {
pub(crate) fn set_cert(&self, provider: &AcmeProvider, cert: Arc<CertifiedKey>) {
// Add certificates
@@ -51,7 +48,7 @@ impl Server {
pub(crate) async fn build_acme_certificate(&self, domain: &str) -> Option<Arc<CertifiedKey>> {
match self
.in_memory_store()
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(KV_ACME, domain))
.key_get::<UnversionedArchive<AlignedBytes>>(KeyValue::<()>::build_key(KV_ACME, domain))
.await
{
Ok(Some(cert_)) => match cert_.unarchive::<SerializedCert>() {