pub struct CaStore {
dir: PathBuf,
}Expand description
The local certificate authority’s own certificate and key, in a directory of their own.
One directory per machine rather than per data directory: a developer
trusts this certificate once, and a second server started with a second
--data must present leaves the same trusted authority signed.
Fields§
§dir: PathBufImplementations§
Source§impl CaStore
impl CaStore
Sourcepub fn open(dir: &Path) -> Result<Self, StorageError>
pub fn open(dir: &Path) -> Result<Self, StorageError>
Opens dir, creating it 0700 if absent and tightening it if it
already existed.
Sourcepub fn certificate_path(&self) -> PathBuf
pub fn certificate_path(&self) -> PathBuf
Where the certificate sits, whether or not it has been generated yet. This is the file a developer trusts, so it has a path even before it has contents.
Sourcepub fn load(&self) -> Result<Option<(String, String)>, StorageError>
pub fn load(&self) -> Result<Option<(String, String)>, StorageError>
The authority last saved here, as (certificate, key), both PEM.
A key with no certificate, or the reverse, is None: the pair is
useless by halves, and the caller’s answer to both is the same.
Sourcepub fn save(&self, cert_pem: &str, key_pem: &str) -> Result<(), StorageError>
pub fn save(&self, cert_pem: &str, key_pem: &str) -> Result<(), StorageError>
Persists the authority’s certificate and key, both 0600.
The key is committed first and the certificate last, so a crash
between them leaves a key with no certificate — which Self::load
reads as nothing saved, and the next start replaces.