Cargo fmt

This commit is contained in:
Gregory Schier
2026-05-08 12:03:34 -07:00
parent 19ed8c2f0d
commit b0b282535f
25 changed files with 199 additions and 252 deletions
+13 -26
View File
@@ -18,23 +18,14 @@ impl CertificateAuthority {
params.is_ca = IsCa::Ca(BasicConstraints::Unconstrained);
params.key_usages.push(KeyUsagePurpose::KeyCertSign);
params.key_usages.push(KeyUsagePurpose::CrlSign);
params
.distinguished_name
.push(rcgen::DnType::CommonName, "Debug Proxy CA");
params
.distinguished_name
.push(rcgen::DnType::OrganizationName, "Debug Proxy");
params.distinguished_name.push(rcgen::DnType::CommonName, "Debug Proxy CA");
params.distinguished_name.push(rcgen::DnType::OrganizationName, "Debug Proxy");
let key = KeyPair::generate()?;
let ca_cert = params.self_signed(&key)?;
let ca_cert_der = ca_cert.der().clone();
Ok(Self {
ca_cert,
ca_cert_der,
ca_key: key,
cache: Mutex::new(HashMap::new()),
})
Ok(Self { ca_cert, ca_cert_der, ca_key: key, cache: Mutex::new(HashMap::new()) })
}
pub fn ca_pem(&self) -> String {
@@ -53,9 +44,7 @@ impl CertificateAuthority {
}
let mut params = CertificateParams::new(vec![domain.to_string()])?;
params
.distinguished_name
.push(rcgen::DnType::CommonName, domain);
params.distinguished_name.push(rcgen::DnType::CommonName, domain);
let leaf_key = KeyPair::generate()?;
let leaf_cert = params.signed_by(&leaf_key, &self.ca_cert, &self.ca_key)?;
@@ -63,20 +52,18 @@ impl CertificateAuthority {
let cert_der = leaf_cert.der().clone();
let key_der = leaf_key.serialize_der();
let mut config = ServerConfig::builder_with_provider(Arc::new(rustls::crypto::ring::default_provider()))
.with_safe_default_protocol_versions()?
.with_no_client_auth()
.with_single_cert(
vec![cert_der, self.ca_cert_der.clone()],
PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from(key_der)),
)?;
let mut config =
ServerConfig::builder_with_provider(Arc::new(rustls::crypto::ring::default_provider()))
.with_safe_default_protocol_versions()?
.with_no_client_auth()
.with_single_cert(
vec![cert_der, self.ca_cert_der.clone()],
PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from(key_der)),
)?;
config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
let config = Arc::new(config);
self.cache
.lock()
.unwrap()
.insert(domain.to_string(), config.clone());
self.cache.lock().unwrap().insert(domain.to_string(), config.clone());
Ok(config)
}
}