style/fix: cleanup ClientBuilder by removing Option from tls_versions
This commit is contained in:
parent
71140fb18a
commit
42a43f175e
1 changed files with 4 additions and 8 deletions
|
@ -18,7 +18,7 @@ use tokio_rustls::{
|
|||
/// Builder for creating configured [`Client`] instance
|
||||
pub struct ClientBuilder {
|
||||
ss_verifier: Option<Arc<dyn SelfsignedCertVerifier>>,
|
||||
tls_versions: Option<&'static [&'static SupportedProtocolVersion]>,
|
||||
tls_versions: &'static [&'static SupportedProtocolVersion],
|
||||
#[cfg(feature = "hickory")]
|
||||
dns: Option<DnsClient>,
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl ClientBuilder {
|
|||
pub fn new() -> Self {
|
||||
ClientBuilder {
|
||||
ss_verifier: None,
|
||||
tls_versions: None,
|
||||
tls_versions: rustls::DEFAULT_VERSIONS,
|
||||
#[cfg(feature = "hickory")]
|
||||
dns: None,
|
||||
}
|
||||
|
@ -49,11 +49,7 @@ impl ClientBuilder {
|
|||
.unwrap_or_else(|| Arc::new(rustls::crypto::ring::default_provider()));
|
||||
|
||||
let tls_config = rustls::ClientConfig::builder_with_provider(provider.clone())
|
||||
.with_protocol_versions(if let Some(versions) = self.tls_versions {
|
||||
versions
|
||||
} else {
|
||||
rustls::DEFAULT_VERSIONS
|
||||
})
|
||||
.with_protocol_versions(self.tls_versions)
|
||||
.unwrap()
|
||||
.dangerous()
|
||||
.with_custom_certificate_verifier(Arc::new(InternalCertVerifier::from(provider)));
|
||||
|
@ -75,7 +71,7 @@ impl ClientBuilder {
|
|||
mut self,
|
||||
versions: &'static [&'static SupportedProtocolVersion],
|
||||
) -> Self {
|
||||
self.tls_versions = Some(versions);
|
||||
self.tls_versions = versions;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue