pub struct TlsConfig {
pub verify_server: bool,
pub ca_cert_path: Option<PathBuf>,
pub client_cert_path: Option<PathBuf>,
pub client_key_path: Option<PathBuf>,
pub server_name: Option<String>,
}Expand description
TLS configuration options.
Fields§
§verify_server: boolWhether to verify the server certificate.
ca_cert_path: Option<PathBuf>Path to CA certificate file (PEM format).
client_cert_path: Option<PathBuf>Path to client certificate file (PEM format).
client_key_path: Option<PathBuf>Path to client key file (PEM format).
server_name: Option<String>Server name for SNI (Server Name Indication).
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn danger_accept_invalid_certs(self) -> Self
pub fn danger_accept_invalid_certs(self) -> Self
Disables server certificate verification.
§Security Warning
This is a serious security risk in production environments. Disabling certificate verification allows man-in-the-middle attacks.
Only use this for:
- Local development with self-signed certificates
- Testing environments
- Debugging certificate issues (temporarily)
A warning will be logged at runtime when this is enabled.
Sourcepub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
pub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
Sets the CA certificate file for verifying the server.
Sourcepub fn client_cert(
self,
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Self
pub fn client_cert( self, cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Self
Sets the client certificate for mutual TLS.
Sourcepub fn server_name(self, name: impl Into<String>) -> Self
pub fn server_name(self, name: impl Into<String>) -> Self
Sets the server name for SNI.
Sourcepub fn has_client_cert(&self) -> bool
pub fn has_client_cert(&self) -> bool
Returns true if client certificates are configured.
Trait Implementations§
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
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request