Add options for specifying the TLS version (#1315)
This commit is contained in:
		| @@ -16,6 +16,8 @@ use super::request::{Request, RequestBuilder}; | ||||
| use super::response::Response; | ||||
| use super::wait; | ||||
| #[cfg(feature = "__tls")] | ||||
| use crate::tls; | ||||
| #[cfg(feature = "__tls")] | ||||
| use crate::Certificate; | ||||
| #[cfg(any(feature = "native-tls", feature = "__rustls"))] | ||||
| use crate::Identity; | ||||
| @@ -603,6 +605,62 @@ impl ClientBuilder { | ||||
|         self.with_inner(|inner| inner.danger_accept_invalid_certs(accept_invalid_certs)) | ||||
|     } | ||||
|  | ||||
|     /// Set the minimum required TLS version for connections. | ||||
|     /// | ||||
|     /// By default the TLS backend's own default is used. | ||||
|     /// | ||||
|     /// # Errors | ||||
|     /// | ||||
|     /// A value of `tls::Version::TLS_1_3` will cause an error with the | ||||
|     /// `native-tls`/`default-tls` backend. This does not mean the version | ||||
|     /// isn't supported, just that it can't be set as a minimum due to | ||||
|     /// technical limitations. | ||||
|     /// | ||||
|     /// # Optional | ||||
|     /// | ||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||
|     /// feature to be enabled. | ||||
|     #[cfg(feature = "__tls")] | ||||
|     #[cfg_attr( | ||||
|         docsrs, | ||||
|         doc(cfg(any( | ||||
|             feature = "default-tls", | ||||
|             feature = "native-tls", | ||||
|             feature = "rustls-tls" | ||||
|         ))) | ||||
|     )] | ||||
|     pub fn min_tls_version(self, version: tls::Version) -> ClientBuilder { | ||||
|         self.with_inner(|inner| inner.min_tls_version(version)) | ||||
|     } | ||||
|  | ||||
|     /// Set the maximum allowed TLS version for connections. | ||||
|     /// | ||||
|     /// By default there's no maximum. | ||||
|     /// | ||||
|     /// # Errors | ||||
|     /// | ||||
|     /// A value of `tls::Version::TLS_1_3` will cause an error with the | ||||
|     /// `native-tls`/`default-tls` backend. This does not mean the version | ||||
|     /// isn't supported, just that it can't be set as a maximum due to | ||||
|     /// technical limitations. | ||||
|     /// | ||||
|     /// # Optional | ||||
|     /// | ||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||
|     /// feature to be enabled. | ||||
|     #[cfg(feature = "__tls")] | ||||
|     #[cfg_attr( | ||||
|         docsrs, | ||||
|         doc(cfg(any( | ||||
|             feature = "default-tls", | ||||
|             feature = "native-tls", | ||||
|             feature = "rustls-tls" | ||||
|         ))) | ||||
|     )] | ||||
|     pub fn max_tls_version(self, version: tls::Version) -> ClientBuilder { | ||||
|         self.with_inner(|inner| inner.max_tls_version(version)) | ||||
|     } | ||||
|  | ||||
|     /// Force using the native TLS backend. | ||||
|     /// | ||||
|     /// Since multiple TLS backends can be optionally enabled, this option will | ||||
|   | ||||
		Reference in New Issue
	
	Block a user