pub struct CertificateAuthenticator {
pub cert_chain: Vec<CertificateDer<'static>>,
pub private_key: PrivateKeyDer<'static>,
}Expand description
Authenticates to Couchbase using a client TLS certificate (mTLS).
This variant is available when the rustls-tls feature is enabled (and native-tls is not).
Provide a certificate chain and private key to establish mutual TLS with the cluster.
Can be converted into an Authenticator with .into().
§Example
use couchbase::authenticator::CertificateAuthenticator;
use std::fs;
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
use rustls_pki_types::pem::PemObject;
// Load PEM-encoded certificate chain and private key from disk.
let cert_pem = fs::read("client.crt").expect("read cert");
let key_pem = fs::read("client.key").expect("read key");
let certs: Vec<_> = CertificateDer::pem_reader_iter(&mut &cert_pem[..])
.collect::<Result<_, _>>()
.expect("parse certs");
let key = PrivateKeyDer::from_pem_slice(&mut &key_pem[..])
.expect("parse key");
let auth = CertificateAuthenticator::new(certs, key);Fields§
§cert_chain: Vec<CertificateDer<'static>>The client certificate chain (leaf first).
private_key: PrivateKeyDer<'static>The client private key.
Implementations§
Source§impl CertificateAuthenticator
impl CertificateAuthenticator
Sourcepub fn new(
cert_chain: Vec<CertificateDer<'static>>,
private_key: PrivateKeyDer<'static>,
) -> Self
pub fn new( cert_chain: Vec<CertificateDer<'static>>, private_key: PrivateKeyDer<'static>, ) -> Self
Creates a new CertificateAuthenticator from a certificate chain and private key.
Trait Implementations§
Source§impl Clone for CertificateAuthenticator
Available on crate feature rustls-tls and non-crate feature native-tls only.
impl Clone for CertificateAuthenticator
Available on crate feature
rustls-tls and non-crate feature native-tls only.Source§impl Debug for CertificateAuthenticator
impl Debug for CertificateAuthenticator
Source§impl From<CertificateAuthenticator> for Authenticator
Available on crate feature rustls-tls and non-crate feature native-tls only.
impl From<CertificateAuthenticator> for Authenticator
Available on crate feature
rustls-tls and non-crate feature native-tls only.Source§fn from(value: CertificateAuthenticator) -> Self
fn from(value: CertificateAuthenticator) -> Self
Converts to this type from the input type.
Source§impl PartialEq for CertificateAuthenticator
impl PartialEq for CertificateAuthenticator
impl Eq for CertificateAuthenticator
impl StructuralPartialEq for CertificateAuthenticator
Auto Trait Implementations§
impl Freeze for CertificateAuthenticator
impl RefUnwindSafe for CertificateAuthenticator
impl Send for CertificateAuthenticator
impl Sync for CertificateAuthenticator
impl Unpin for CertificateAuthenticator
impl UnsafeUnpin for CertificateAuthenticator
impl UnwindSafe for CertificateAuthenticator
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.