Skip to main content

PKCS11ClientCertResolver

Struct PKCS11ClientCertResolver 

Source
pub struct PKCS11ClientCertResolver { /* private fields */ }

Implementations§

Source§

impl PKCS11ClientCertResolver

Source

pub fn new(pin: Option<&str>, path: &OsStr) -> Result<Self, Box<dyn Error>>

Create a new PKCS11ClientCertResolver.

§Arguments
  • pin - An optional &str of the pin that unlocks the device. Set to None if device does not need a pin to unlock.
  • path - Absolute filepath to the PKCS11 library of your device.
§Examples
let pin = Some("123456");
let tls = rustls::ClientConfig::builder()
   .with_root_certificates(root_certs)
   .with_client_cert_resolver(Arc::new(
       PKCS11ClientCertResolver::new(pin, "/usr/lib/opensc-pkcs11.so")?
   ));
§Errors

Authenticator devices are complicated things. A lot can go wrong along the way. To alleviate this, most checks happen at instantiation time here, therefore errors yielded here can have a plethora of reasons:

  • the PKCS11 library could not be loaded under the file path.
  • the pin is missing or incorrect.
  • the authenticator device is not present or inaccessible.
  • the PKCS11 library has problems communicating with the authenticator device.
  • the authenticator device cannot read an appropriate certificate from the relevant slot.
  • the authenticator device’s certificate signature scheme is not supported.

Trait Implementations§

Source§

impl Debug for PKCS11ClientCertResolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ResolvesClientCert for PKCS11ClientCertResolver

Source§

fn resolve( &self, _acceptable_issuers: &[&[u8]], _sigschemes: &[SignatureScheme], ) -> Option<Arc<CertifiedKey>>

Resolve a client certificate chain/private key to use as the client’s identity. Read more
Source§

fn has_certs(&self) -> bool

Return true if any certificates at all are available.
Source§

fn only_raw_public_keys(&self) -> bool

Return true if the client only supports raw public keys. Read more

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.