pub struct CertStore<'a> { /* private fields */ }Expand description
A unified interface to multiple certificate stores.
When a certificate is looked up, the certificate is looked up in
the primary cert-d, if any, and all the backends whose access mode
is AccessMode::Always. The results are merged and returned. If
no certificate is found, then the look up is also tried on the
backends whose access mode is AccessMode::OnMiss. Finally, if a
key server is configured, the key server is tried.
In general, results are preferred to errors. That is, if a
backend returns a positive result, and another backend returns an
error, the error is ignored, even if it is something other than
StoreError::NotFound.
Results from the key server are either cached when
CertStore::flush is called (or the CertStore is dropped)
if there is a writable primary cert-d, or simply dropped
otherwise.
Implementations§
Source§impl<'a> CertStore<'a>
impl<'a> CertStore<'a>
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Returns a CertStore, which uses the default certificate directory.
When a certificate is added or updated, it will be added to or updated in this certificate store.
Sourcepub fn readonly() -> Result<Self>
pub fn readonly() -> Result<Self>
Returns a CertStore, which uses the default certificate directory in read-only mode.
Sourcepub fn open<P>(path: P) -> Result<Self>
pub fn open<P>(path: P) -> Result<Self>
Returns a CertStore, which uses the specified certificate directory.
When a certificate is added or updated, it will be added to or updated in this certificate store.
Sourcepub fn open_readonly<P>(path: P) -> Result<Self>
pub fn open_readonly<P>(path: P) -> Result<Self>
Returns a CertStore, which uses the specified certificate directory in read-only mode.
Sourcepub fn add_backend(
&mut self,
backend: Box<dyn Store<'a> + Send + Sync + 'a>,
mode: AccessMode,
) -> &mut Self
pub fn add_backend( &mut self, backend: Box<dyn Store<'a> + Send + Sync + 'a>, mode: AccessMode, ) -> &mut Self
Add the specified backend to the CertStore.
The backend is added to the collection of read-only backends.
Sourcepub fn add_certd<P>(&mut self, path: P) -> Result<&mut Self>
pub fn add_certd<P>(&mut self, path: P) -> Result<&mut Self>
Adds the specified cert-d to the CertStore.
The cert-d is added in read-only mode, and its access mode is
set to AccessMode::Always.
Sourcepub fn add_default_certd(&mut self) -> Result<&mut Self>
pub fn add_default_certd(&mut self) -> Result<&mut Self>
Adds the default cert-d to the CertStore.
The cert-d is added in read-only mode, and its access mode is
set to AccessMode::Always.
Sourcepub fn add_keyring<P>(&mut self, path: P) -> Result<&mut Self>
pub fn add_keyring<P>(&mut self, path: P) -> Result<&mut Self>
Adds the specified keyring to the CertStore.
The keyring is added in read-only mode, and its access mode is
set to AccessMode::Always.
Sourcepub fn add_keyrings<I, P>(&mut self, filenames: I) -> Result<&mut Self>
pub fn add_keyrings<I, P>(&mut self, filenames: I) -> Result<&mut Self>
Adds the specified keyrings to the CertStore.
The keyrings are added in read-only mode, and their access
mode is set to AccessMode::Always.
Sourcepub fn add_keyserver(&mut self, url: &str) -> Result<&mut Self>
pub fn add_keyserver(&mut self, url: &str) -> Result<&mut Self>
Adds the specified keyserver to the CertStore.
The keyserver is added in read-only mode, and its access mode
is set to AccessMode::OnMiss.
Sourcepub fn add_keyserver_backend(&mut self, ks: KeyServer<'a>) -> Result<&mut Self>
pub fn add_keyserver_backend(&mut self, ks: KeyServer<'a>) -> Result<&mut Self>
Adds the specified keyserver to the CertStore.
The keyserver is added in read-only mode, and its access mode
is set to AccessMode::OnMiss.
A key server is treated specially from other backends: any results that it returns are written to the cert store (if it is open in read-write mode).
Source§impl<'a> CertStore<'a>
impl<'a> CertStore<'a>
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Flushes any modified certificates to the backing store.
Currently, this flushes the key server cache to the underlying cert-d, if any. All other backends are currently expected to work in a write-through manner.
Note: this is called automatically when the CertStore is
dropped, but calling it explicitly allows for reporting of
errors.