mirror of
https://github.com/lldap/lldap.git
synced 2026-06-18 23:58:25 +00:00
This commit upgrades the TLS stack to Rustls 0.23 Key changes: - Dependencies: Updated 'rustls' (v0.23), 'tokio-rustls' (v0.26), and 'actix-web' (v4.12.1). - Build Fix: Configured 'rustls' to use the 'ring' provider (disabling default 'aws-lc-rs') to ensure ARMv7 compatibility. - Refactor: Created 'server/src/tls.rs' to handle certificate loading (DRY). - LDAP: Updated 'ldap_server.rs' to use the new TLS module and Rustls APIs. - Healthcheck: Updated 'healthcheck.rs' to use Rustls 0.23 types.
21 lines
789 B
Rust
21 lines
789 B
Rust
use anyhow::{Context, Result, anyhow};
|
|
use rustls::pki_types::{CertificateDer, PrivateKeyDer, pem::PemObject};
|
|
|
|
pub fn load_certificates(filename: &str) -> Result<Vec<CertificateDer<'static>>> {
|
|
let certs = CertificateDer::pem_file_iter(filename)
|
|
.with_context(|| format!("Unable to open or read certificate file: {}", filename))?
|
|
.collect::<Result<Vec<_>, _>>()
|
|
.with_context(|| format!("Error parsing certificates in {}", filename))?;
|
|
|
|
if certs.is_empty() {
|
|
return Err(anyhow!("No certificates found in {}", filename));
|
|
}
|
|
|
|
Ok(certs)
|
|
}
|
|
|
|
pub fn load_private_key(filename: &str) -> Result<PrivateKeyDer<'static>> {
|
|
PrivateKeyDer::from_pem_file(filename)
|
|
.with_context(|| format!("Unable to load private key from {}", filename))
|
|
}
|