pub struct SslOpts { /* private fields */ }
Expand description
Ssl Options.
// With native-tls
let ssl_opts = SslOpts::default()
.with_client_identity(Some(ClientIdentity::new(Path::new("/path").into())
.with_password("******")
));
// With rustls
let ssl_opts = SslOpts::default()
.with_client_identity(Some(ClientIdentity::new(
Path::new("/path/to/chain").into(),
Path::new("/path/to/priv_key").into(),
)));
Implementations§
Source§impl SslOpts
impl SslOpts
Sourcepub fn with_root_certs(self, root_certs: Vec<PathOrBuf<'static>>) -> Self
pub fn with_root_certs(self, root_certs: Vec<PathOrBuf<'static>>) -> Self
Sets path to a pem
or der
certificate of the root that connector will trust.
Multiple certs are allowed in .pem files.
All the elements in root_certs
will be merged.
Sourcepub fn with_disable_built_in_roots(self, disable_built_in_roots: bool) -> Self
pub fn with_disable_built_in_roots(self, disable_built_in_roots: bool) -> Self
If true
, use only the root certificates configured via SslOpts::with_root_certs
,
not any system or built-in certs. By default system built-in certs will be used.
§Connection URL
Use built_in_roots
URL parameter to set this value:
let opts = Opts::from_url("mysql://localhost/db?require_ssl=true&built_in_roots=false")?;
assert_eq!(opts.ssl_opts().unwrap().disable_built_in_roots(), true);
Sourcepub fn with_danger_skip_domain_validation(self, value: bool) -> Self
pub fn with_danger_skip_domain_validation(self, value: bool) -> Self
The way to not validate the server’s domain name against its certificate. By default domain name will be validated.
§Connection URL
Use verify_identity
URL parameter to set this value:
let opts = Opts::from_url("mysql://localhost/db?require_ssl=true&verify_identity=false")?;
assert_eq!(opts.ssl_opts().unwrap().skip_domain_validation(), true);
Sourcepub fn with_danger_accept_invalid_certs(self, value: bool) -> Self
pub fn with_danger_accept_invalid_certs(self, value: bool) -> Self
If true
then client will accept invalid certificate (expired, not trusted, ..).
Invalid certificates won’t get accepted by default.
§Connection URL
Use verify_ca
URL parameter to set this value:
let opts = Opts::from_url("mysql://localhost/db?require_ssl=true&verify_ca=false")?;
assert_eq!(opts.ssl_opts().unwrap().accept_invalid_certs(), true);
Sourcepub fn with_danger_tls_hostname_override<T: Into<Cow<'static, str>>>(
self,
domain: Option<T>,
) -> Self
pub fn with_danger_tls_hostname_override<T: Into<Cow<'static, str>>>( self, domain: Option<T>, ) -> Self
If set, will override the hostname used to verify the server’s certificate.
This is useful when connecting to a server via a tunnel, where the server hostname is different from the hostname used to connect to the tunnel.
pub fn root_certs(&self) -> &[PathOrBuf<'static>]
pub fn disable_built_in_roots(&self) -> bool
pub fn skip_domain_validation(&self) -> bool
pub fn accept_invalid_certs(&self) -> bool
pub fn tls_hostname_override(&self) -> Option<&str>
Trait Implementations§
impl Eq for SslOpts
impl StructuralPartialEq for SslOpts
Auto Trait Implementations§
impl Freeze for SslOpts
impl RefUnwindSafe for SslOpts
impl Send for SslOpts
impl Sync for SslOpts
impl Unpin for SslOpts
impl UnwindSafe for SslOpts
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.