config.rs

Overview

The config.rs file provides abstractions and utilities for managing TLS certificates and private keys within the system. It defines structures for loading, storing, serializing, and deserializing certificates and private keys from filesystem paths. It also supports the resolution of certificates and keys for TLS usage, including integration with a certificate cache or on-demand self-signed certificate generation. This file encapsulates certificate and key handling logic, ensuring safe and traceable loading and reuse of cryptographic materials.

Main Entities and Their Functionalities

CertFile

Represents a TLS certificate loaded from a file path.


CertStore

Represents a collection of trusted CA certificates loaded from specified paths.


PrivateKeyFile

Represents a private key loaded from a file.


Serialization and Deserialization

This design allows configuration files or other serialized forms to store just paths, deferring actual certificate/key loading to runtime.

Implementation Details and Algorithms

Interactions with Other System Components

The file acts as a bridge between filesystem-based PEM certificate/key files and the internal TLS configuration of the application, facilitating secure communication.

Constants

Testing


Mermaid Diagram

classDiagram
class CertFile {
+path: PathBuf
-cert: Option<CertificateDer>
+try_new()
+resolve()
+try_load_certs()
}
class CertStore {
+paths: Vec<PathBuf>
+certs: Vec<CertificateDer>
+try_new()
+cert_hashes()
}
class PrivateKeyFile {
+path: PathBuf
+key: Option<PrivateKeyDer>
+try_new()
+clone()
}
CertFile --> CertificateDer : contains
PrivateKeyFile --> PrivateKeyDer : contains
CertStore --> CertificateDer : aggregates
CertFile ..> PrivateKeyFile : uses in resolve()
CertFile ..> TlsCertCache : optional dependency
CertFile ..> transport_layer.SigningKey : uses for Ed25519 keys