pub struct TlsConfig {
pub ca_cert_path: Option<PathBuf>,
pub client_cert_path: Option<PathBuf>,
pub client_key_path: Option<PathBuf>,
pub danger_skip_verify: bool,
pub server_name: Option<String>,
}Expand description
TLS/SSL configuration for MySQL connections.
This struct holds the certificate and key paths for TLS connections.
The actual TLS implementation requires the tls feature to be enabled.
Fields§
§ca_cert_path: Option<PathBuf>Path to CA certificate file (PEM format) for server verification.
Required for SslMode::VerifyCa and SslMode::VerifyIdentity.
client_cert_path: Option<PathBuf>Path to client certificate file (PEM format) for mutual TLS. Optional - only needed if server requires client certificate.
client_key_path: Option<PathBuf>Path to client private key file (PEM format) for mutual TLS.
Required if client_cert_path is set.
danger_skip_verify: boolSkip server certificate verification.
§Security Warning
Setting this to true disables certificate verification, making the
connection vulnerable to man-in-the-middle attacks. Only use for
development/testing with self-signed certificates.
server_name: Option<String>Server name for SNI (Server Name Indication). If not set, defaults to the connection hostname.
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn client_cert(self, path: impl Into<PathBuf>) -> Self
pub fn client_cert(self, path: impl Into<PathBuf>) -> Self
Set the client certificate path.
Sourcepub fn client_key(self, path: impl Into<PathBuf>) -> Self
pub fn client_key(self, path: impl Into<PathBuf>) -> Self
Set the client key path.
Sourcepub fn skip_verify(self, skip: bool) -> Self
pub fn skip_verify(self, skip: bool) -> Self
Skip server certificate verification (dangerous!).
Sourcepub fn server_name(self, name: impl Into<String>) -> Self
pub fn server_name(self, name: impl Into<String>) -> Self
Set the server name for SNI.
Sourcepub fn has_client_cert(&self) -> bool
pub fn has_client_cert(&self) -> bool
Check if mutual TLS (client certificate) is configured.