pub struct CertStore<'store> { /* private fields */ }Expand description
Store for OpenPGP certificates with public material only, i.e. public keys and user IDs.
Implementations§
Source§impl<'store> CertStore<'store>
impl<'store> CertStore<'store>
Sourcepub fn default_location() -> Result<PathBuf, Error>
pub fn default_location() -> Result<PathBuf, Error>
Returns the default path for the certificate store.
Sourcepub fn open(opts: &CertStoreOpts<'_>) -> Result<CertStore<'store>, Error>
pub fn open(opts: &CertStoreOpts<'_>) -> Result<CertStore<'store>, Error>
Open a certificate store from disk.
If no path is provided, the certificate store will be created at the default, platform-specific, location.
Sourcepub fn open_ephemeral() -> CertStore<'store>
pub fn open_ephemeral() -> CertStore<'store>
Opens an in-memory certificate store.
Sourcepub fn get_cert_path(
&self,
fingerprint: &Fingerprint,
) -> Result<PathBuf, PgpError>
pub fn get_cert_path( &self, fingerprint: &Fingerprint, ) -> Result<PathBuf, PgpError>
Returns OpenPGP certificate file location on disk.
- The certificate is specified via the fingerprint of the primary key.
- If the certificate is not present in the store, an error is returned.
Certificates are stored as files under the path:
/path/of/store/<first 2 chars of fingerprint>/<remainder of fingerprint>.- Example:
~/.local/share/pgp.cert.d/1e/a0292ecbf2457cadae20e2b94fa6a56d9fa1fb.
Sourcepub fn import(&mut self, cert: &Cert) -> Result<Cert, PgpError>
pub fn import(&mut self, cert: &Cert) -> Result<Cert, PgpError>
Add an OpenPGP certificate to a local store.
Only the public part of the certificate is stored in the store. If a certificate with the same fingerprint is already present, it gets updated with the new material (if any) present in the certificate being added.
Sourcepub fn get_cert(
&self,
query_term: &QueryTerm<'_>,
) -> Result<Vec<Cert>, PgpError>
pub fn get_cert( &self, query_term: &QueryTerm<'_>, ) -> Result<Vec<Cert>, PgpError>
Retrieve OpenPGP certificates from the CertStore by searching for a
query_term that can be either a fingerprint or an email address.
- The function returns a
Vecof certificates, because there can be multiple certificates with the same email in the store. - If no certificates matching the specified
query_termis found, an error is returned.
§Arguments
query_term: fingerprint or an email address of the certificate to retrieve. Must be passed as aQueryTermvariant.
Sourcepub fn certs<'a>(
&'a self,
) -> Box<dyn Iterator<Item = Result<Cert, PgpError>> + 'a>
pub fn certs<'a>( &'a self, ) -> Box<dyn Iterator<Item = Result<Cert, PgpError>> + 'a>
Retrieves all certificates from the store.
Excludes special certificates as described in
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html#name-special-names
(currently only trust-root).
Sourcepub fn trust_root(&self) -> Result<Cert, PgpError>
pub fn trust_root(&self) -> Result<Cert, PgpError>
Returns store’s local trust root certificate
Sourcepub fn certify(
&self,
cert: &Cert,
trust_amount: TrustAmount,
) -> Result<(Cert, bool), PgpError>
pub fn certify( &self, cert: &Cert, trust_amount: TrustAmount, ) -> Result<(Cert, bool), PgpError>
Manage user ID certifications
This function adds or removes certifications for all valid self-signed UserID packets. It uses the Trust Root certificate from the user’s certificate store to perform these actions.
On successful execution, it returns a certificate that includes the updated certifications along with a status indicator. This status indicates whether the certificate has been modified, specifically if new certifications have been added or existing ones removed.
Auto Trait Implementations§
impl<'store> !Freeze for CertStore<'store>
impl<'store> !RefUnwindSafe for CertStore<'store>
impl<'store> Send for CertStore<'store>
impl<'store> Sync for CertStore<'store>
impl<'store> Unpin for CertStore<'store>
impl<'store> !UnwindSafe for CertStore<'store>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more