pub struct TlsConfig { /* private fields */ }Expand description
What a store needs to speak TLS to somewhere this machine does not already trust.
Data only — no client type appears anywhere in it, which is what makes
it the same three settings in all seven crates and what makes it
expressible from a language that has never heard of tonic.
Empty by default, and an empty one is not “no TLS”: it is the platform’s own trust store, which is what a public certificate authority needs and what every store already did.
See the module documentation for what each store can express.
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn new() -> TlsConfig
pub fn new() -> TlsConfig
An empty configuration: the platform’s trust store, no client certificate.
Sourcepub fn with_ca_certificate_file(self, path: impl Into<PathBuf>) -> TlsConfig
pub fn with_ca_certificate_file(self, path: impl Into<PathBuf>) -> TlsConfig
Trust the certificate authority in this PEM file.
The file may hold several certificates; all of them are trusted, which is what a private CA with an intermediate needs.
The file is read when the store builds its client, not here — so a rotated CA is picked up by rebuilding the source, and a missing file is an error naming it rather than a panic in a builder chain.
Sourcepub fn with_ca_certificate_pem(self, pem: impl Into<Vec<u8>>) -> TlsConfig
pub fn with_ca_certificate_pem(self, pem: impl Into<Vec<u8>>) -> TlsConfig
Trust the certificate authority in these PEM bytes.
For a program that already has the material — from a secrets manager, from its own configuration — and should not have to put it on a disk for a client to read back.
Sourcepub fn with_client_certificate_files(
self,
certificate: impl Into<PathBuf>,
key: impl Into<PathBuf>,
) -> TlsConfig
pub fn with_client_certificate_files( self, certificate: impl Into<PathBuf>, key: impl Into<PathBuf>, ) -> TlsConfig
Present this client certificate and private key (mTLS).
Both are PEM files. certificate may be a chain; the leaf comes
first, as every TLS stack here expects.
Sourcepub fn with_client_certificate_pem(
self,
certificate: impl Into<Vec<u8>>,
key: impl Into<Vec<u8>>,
) -> TlsConfig
pub fn with_client_certificate_pem( self, certificate: impl Into<Vec<u8>>, key: impl Into<Vec<u8>>, ) -> TlsConfig
Present this client certificate and private key (mTLS), from bytes.
The private key is the sharpest secret this crate handles. It is
never rendered by Debug, never quoted into an
error, and never written anywhere: it goes from here into the
client’s own key type and stops.
Sourcepub fn with_server_name(self, name: impl Into<String>) -> TlsConfig
pub fn with_server_name(self, name: impl Into<String>) -> TlsConfig
Verify the certificate against this name rather than the address’s.
For an endpoint written as an IP — a Service’s cluster IP, a load
balancer, a NodePort — against a certificate issued for a
hostname. The certificate still has to chain to a trusted authority
and still has to carry this name; only which name is checked moves.
Refused by the stores whose clients cannot express it; see the module documentation.
Sourcepub fn with_skip_verification(self, skip: bool) -> TlsConfig
pub fn with_skip_verification(self, skip: bool) -> TlsConfig
Do not authenticate the server at all.
This is not a weaker TLS; it is TLS without the part that makes it mean anything. Any party on the network path can present any certificate, read what is sent, and rewrite what comes back — and what comes back from a store is the configuration and the credentials a process is about to run on.
Try with_ca_certificate_file
first. A development server with a self-signed certificate and an
enterprise private CA are both one more certificate to trust, which
is one line and keeps the server authenticated.
Refused by the stores whose clients cannot express it; see the module documentation.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this asks for nothing at all.
A store uses it to tell “the caller wants the platform defaults” from “the caller wants something”, which is the difference between leaving its client alone and building one.
Sourcepub fn ca_certificate(&self) -> Option<&Pem>
pub fn ca_certificate(&self) -> Option<&Pem>
The certificate authority to trust, if one was named.
Sourcepub fn client_certificate(&self) -> Option<&ClientCertificate>
pub fn client_certificate(&self) -> Option<&ClientCertificate>
The client certificate to present, if one was named.
Sourcepub fn server_name(&self) -> Option<&str>
pub fn server_name(&self) -> Option<&str>
The name to verify against, if it is not the address’s.
Sourcepub const fn skips_verification(&self) -> bool
pub const fn skips_verification(&self) -> bool
Whether the server is to go unauthenticated.
Trait Implementations§
impl Eq for TlsConfig
impl StructuralPartialEq for TlsConfig
Auto Trait Implementations§
impl Freeze for TlsConfig
impl RefUnwindSafe for TlsConfig
impl Send for TlsConfig
impl Sync for TlsConfig
impl Unpin for TlsConfig
impl UnsafeUnpin for TlsConfig
impl UnwindSafe for TlsConfig
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> 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.