Skip to main content

ClientIdentity

Struct ClientIdentity 

Source
pub struct ClientIdentity {
    pub cert_chain_pem: Vec<u8>,
    pub key_pem: Vec<u8>,
    pub key_passphrase: Option<String>,
}
Expand description

A client certificate and its private key, for TLS client authentication.

Both are PEM-encoded. A remote that authenticates its clients with TLS needs an identity.

Fields§

§cert_chain_pem: Vec<u8>

The client certificate, followed by any intermediate certificates.

If the blob holds no certificate, Fetcher::new returns Error::Fetch.

§key_pem: Vec<u8>

The private key of the client certificate.

The blob holds one section or more. The fetcher reads the first section whose armor label names a private key, and that section selects the path:

  • A PRIVATE KEY, RSA PRIVATE KEY, or EC PRIVATE KEY section is read as it is.
  • An ENCRYPTED PRIVATE KEY section is PKCS#8 under PBES2. key_passphrase decrypts it.

If the blob holds no private key section, Fetcher::new returns Error::Fetch.

§key_passphrase: Option<String>

The passphrase of an encrypted PKCS#8 private key.

If this is set and the key section carries no encryption, the fetcher refuses the key. A passphrase that decrypts nothing hides a configuration mistake.

§Algorithms

  • Ciphers: AES-128-CBC, AES-192-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM.
  • GCM parameters: a 12-byte nonce as a bare OCTET STRING. The 16-byte tag is at the end of the ciphertext.
  • Key derivation functions: PBKDF2 with an HMAC-SHA-2 pseudorandom function, and scrypt.

§Key derivation cost

The key file sets the cost of the key derivation. The iteration count of PBKDF2 and the cost parameter of scrypt come from the file. A file with an extreme parameter uses that much processor time or memory. The operator supplies the key file, so ostrya applies no bound to either parameter.

§Refusals

Fetcher::new returns Error::Fetch, with a message of its own, in each of these cases:

  • The key is encrypted, and no passphrase is set.
  • A passphrase is set, and the key section carries no encryption.
  • The passphrase does not decrypt the key.
  • This build has no implementation of the PBES2 cipher or key derivation function. The message names the OID. DES, 3DES, and PBKDF2 with an HMAC-SHA-1 pseudorandom function get this refusal.
  • The key is under PKCS#5 PBES1, which the pkcs5 crate parses and does not decrypt. The message names PBES1. pkcs5 recognizes six PBES1 OIDs, and an OID outside that set gives a DER decoding failure. A corrupted document gives the same failure, so the two cases look the same.
  • The parameters of a GCM cipher are the RFC 5084 GCMParameters SEQUENCE. The message is a DER decoding failure.
  • The salt of PBKDF2 or scrypt is longer than 32 bytes. The message is a DER decoding failure. The OpenSSL default salt is 16 bytes.
  • The key is in the legacy OpenSSL traditional PEM format, with a Proc-Type: 4,ENCRYPTED header line in the section. The message names the openssl pkcs8 -topk8 conversion, which gives a PKCS#8 key. This refusal applies with or without a passphrase.

Trait Implementations§

Source§

impl Clone for ClientIdentity

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientIdentity

Redacts the private key and the passphrase.

A logged configuration holds neither. The key shows as its length in bytes, and the passphrase shows as "<redacted>" if it is set. The certificate chain is public material and shows in full.

Source§

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

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

impl Eq for ClientIdentity

Source§

impl PartialEq for ClientIdentity

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ClientIdentity

Auto Trait Implementations§

§

impl Forget for ClientIdentity

§

impl Freeze for ClientIdentity
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for ClientIdentity

§

impl RefUnwindSafe for ClientIdentity

§

impl Send for ClientIdentity
where RawVecInner: Send,

§

impl Sync for ClientIdentity
where RawVecInner: Sync,

§

impl Unpin for ClientIdentity
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for ClientIdentity

§

impl UnwindSafe for ClientIdentity
where RawVecInner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
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