Struct hyper_rustls::HttpsConnectorBuilder
source · pub struct HttpsConnectorBuilder<State>(/* private fields */);
Expand description
A builder for an HttpsConnector
This makes configuration flexible and explicit and ensures connector features match crate features
§Examples
use hyper_rustls::HttpsConnectorBuilder;
let https = HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_only()
.enable_http1()
.build();
Implementations§
source§impl ConnectorBuilder<WantsTlsConfig>
impl ConnectorBuilder<WantsTlsConfig>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ConnectorBuilder
sourcepub fn with_tls_config(
self,
config: ClientConfig,
) -> ConnectorBuilder<WantsSchemes>
pub fn with_tls_config( self, config: ClientConfig, ) -> ConnectorBuilder<WantsSchemes>
Passes a rustls ClientConfig
to configure the TLS connection
The alpn_protocols
field is
required to be empty (or the function will panic) and will be
rewritten to match the enabled schemes (see
enable_http1
,
enable_http2
) before the
connector is built.
sourcepub fn with_platform_verifier(self) -> ConnectorBuilder<WantsSchemes>
Available on (crate features ring
or aws-lc-rs
) and crate feature rustls-platform-verifier
only.
pub fn with_platform_verifier(self) -> ConnectorBuilder<WantsSchemes>
ring
or aws-lc-rs
) and crate feature rustls-platform-verifier
only.Shorthand for using rustls’ default crypto provider and other defaults, and the platform verifier.
sourcepub fn with_provider_and_platform_verifier(
self,
provider: impl Into<Arc<CryptoProvider>>,
) -> Result<ConnectorBuilder<WantsSchemes>>
Available on crate feature rustls-platform-verifier
only.
pub fn with_provider_and_platform_verifier( self, provider: impl Into<Arc<CryptoProvider>>, ) -> Result<ConnectorBuilder<WantsSchemes>>
rustls-platform-verifier
only.Shorthand for using a custom CryptoProvider
and the platform verifier.
sourcepub fn with_native_roots(self) -> Result<ConnectorBuilder<WantsSchemes>>
Available on (crate features ring
or aws-lc-rs
) and crate feature rustls-native-certs
only.
pub fn with_native_roots(self) -> Result<ConnectorBuilder<WantsSchemes>>
ring
or aws-lc-rs
) and crate feature rustls-native-certs
only.Shorthand for using rustls’ default crypto provider and safe defaults, with native roots.
sourcepub fn with_provider_and_native_roots(
self,
provider: impl Into<Arc<CryptoProvider>>,
) -> Result<ConnectorBuilder<WantsSchemes>>
Available on crate feature rustls-native-certs
only.
pub fn with_provider_and_native_roots( self, provider: impl Into<Arc<CryptoProvider>>, ) -> Result<ConnectorBuilder<WantsSchemes>>
rustls-native-certs
only.Shorthand for using a custom CryptoProvider
and native roots
sourcepub fn with_webpki_roots(self) -> ConnectorBuilder<WantsSchemes>
Available on (crate features ring
or aws-lc-rs
) and crate feature webpki-roots
only.
pub fn with_webpki_roots(self) -> ConnectorBuilder<WantsSchemes>
ring
or aws-lc-rs
) and crate feature webpki-roots
only.Shorthand for using rustls’ default crypto provider and its safe defaults.
sourcepub fn with_provider_and_webpki_roots(
self,
provider: impl Into<Arc<CryptoProvider>>,
) -> Result<ConnectorBuilder<WantsSchemes>, Error>
Available on crate feature webpki-roots
only.
pub fn with_provider_and_webpki_roots( self, provider: impl Into<Arc<CryptoProvider>>, ) -> Result<ConnectorBuilder<WantsSchemes>, Error>
webpki-roots
only.Shorthand for using a custom CryptoProvider
, Rustls’ safe default
protocol versions and Mozilla roots
source§impl ConnectorBuilder<WantsSchemes>
impl ConnectorBuilder<WantsSchemes>
sourcepub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>
pub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>
Enforce the use of HTTPS when connecting
Only URLs using the HTTPS scheme will be connectable.
sourcepub fn https_or_http(self) -> ConnectorBuilder<WantsProtocols1>
pub fn https_or_http(self) -> ConnectorBuilder<WantsProtocols1>
Allow both HTTPS and HTTP when connecting
HTTPS URLs will be handled through rustls, HTTP URLs will be handled by the lower-level connector.
source§impl ConnectorBuilder<WantsProtocols1>
impl ConnectorBuilder<WantsProtocols1>
sourcepub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>
Available on crate feature http1
only.
pub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>
http1
only.Enable HTTP1
This needs to be called explicitly, no protocol is enabled by default
sourcepub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>
Available on crate feature http2
only.
pub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>
http2
only.Enable HTTP2
This needs to be called explicitly, no protocol is enabled by default
sourcepub fn enable_all_versions(self) -> ConnectorBuilder<WantsProtocols3>
Available on crate feature http2
only.
pub fn enable_all_versions(self) -> ConnectorBuilder<WantsProtocols3>
http2
only.Enable all HTTP versions built into this library (enabled with Cargo features)
For now, this could enable both HTTP 1 and 2, depending on active features. In the future, other supported versions will be enabled as well.
sourcepub fn with_server_name_resolver(
self,
resolver: impl ResolveServerName + 'static + Sync + Send,
) -> Self
pub fn with_server_name_resolver( self, resolver: impl ResolveServerName + 'static + Sync + Send, ) -> Self
Override server name for the TLS stack
By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.
If this method is called, hyper-rustls will instead use this resolver to compute the value used to verify the server certificate.
sourcepub fn with_server_name(self, override_server_name: String) -> Self
👎Deprecated since 0.27.1: use Self::with_server_name_resolver with FixedServerNameResolver instead
pub fn with_server_name(self, override_server_name: String) -> Self
Override server name for the TLS stack
By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.
If this method is called, hyper-rustls will instead verify that server
certificate contains override_server_name
. Domain name included in
the URL will not affect certificate validation.
source§impl ConnectorBuilder<WantsProtocols2>
impl ConnectorBuilder<WantsProtocols2>
sourcepub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>
Available on crate feature http2
only.
pub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>
http2
only.Enable HTTP2
This needs to be called explicitly, no protocol is enabled by default
sourcepub fn build(self) -> HttpsConnector<HttpConnector>
pub fn build(self) -> HttpsConnector<HttpConnector>
This builds an HttpsConnector
built on hyper’s default HttpConnector
sourcepub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
This wraps an arbitrary low-level connector into an HttpsConnector
source§impl ConnectorBuilder<WantsProtocols3>
impl ConnectorBuilder<WantsProtocols3>
sourcepub fn build(self) -> HttpsConnector<HttpConnector>
Available on crate feature http2
only.
pub fn build(self) -> HttpsConnector<HttpConnector>
http2
only.This builds an HttpsConnector
built on hyper’s default HttpConnector
sourcepub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
Available on crate feature http2
only.
pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
http2
only.This wraps an arbitrary low-level connector into an HttpsConnector