[go: up one dir, main page]

CertStore

Struct CertStore 

Source
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>

Source

pub fn default_location() -> Result<PathBuf, Error>

Returns the default path for the certificate store.

Source

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.

Source

pub fn open_ephemeral() -> CertStore<'store>

Opens an in-memory certificate store.

Source

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.
Source

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.

Source

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 Vec of certificates, because there can be multiple certificates with the same email in the store.
  • If no certificates matching the specified query_term is found, an error is returned.
§Arguments
  • query_term: fingerprint or an email address of the certificate to retrieve. Must be passed as a QueryTerm variant.
Source

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).

Source

pub fn trust_root(&self) -> Result<Cert, PgpError>

Returns store’s local trust root certificate

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,