pub struct CaTlsConfig { /* private fields */ }Expand description
Configures the trusted CA root certificates for non-iroh TLS connections.
These roots are used whenever iroh establishes standard TLS connections to external services, such as iroh relays, pkarr servers, or DNS-over-HTTPS resolvers.
The configured Certificate Authority (CA) roots are only used for verifying the validity of TLS certificates presented by those external services. These CAs don’t need to be trusted for the integrity or authenticity of native iroh connections, which rely on iroh’s own cryptographic authentication mechanisms.
Implementations§
Source§impl CaTlsConfig
impl CaTlsConfig
Sourcepub fn system() -> Self
Available on crate feature platform-verifier only.
pub fn system() -> Self
platform-verifier only.Uses the operating system’s certificate facilities for verifying the validity of TLS certificates.
See [rustls_platform_verifier] for details how trust anchors are retrieved on different platforms.
Note: Additional certificates added via Self::with_extra_roots will be ignored on Android due to
missing support in [rustls].
Sourcepub fn embedded() -> Self
pub fn embedded() -> Self
Uses a compiled-in copy of the root certificates trusted by Mozilla.
See [webpki_roots] for details.
Sourcepub fn insecure_skip_verify() -> Self
Available on crate features test-utils only.
pub fn insecure_skip_verify() -> Self
test-utils only.INSECURE: Do not verify server certificates at all.
May only be used in tests or local development setups.
Sourcepub fn custom_roots(
roots: impl IntoIterator<Item = CertificateDer<'static>>,
) -> Self
pub fn custom_roots( roots: impl IntoIterator<Item = CertificateDer<'static>>, ) -> Self
Only trusts the explicitly set root certificates.
Sourcepub fn custom(roots: impl IntoIterator<Item = CertificateDer<'static>>) -> Self
👎Deprecated since 1.0.0: Renamed to custom_roots
pub fn custom(roots: impl IntoIterator<Item = CertificateDer<'static>>) -> Self
custom_rootsRenamed to Self::custom_roots.
Sourcepub fn custom_server_cert_verifier(builder: ServerCertVerifierBuilder) -> Self
pub fn custom_server_cert_verifier(builder: ServerCertVerifierBuilder) -> Self
Creates a CaTlsConfig that uses a callback function to create a [ServerCertVerifier].
This is an advanced feature and you should only use this if none of the other constructor functions cover your needs. Wrongly implementing the callback may lead to insecure connections being accepted.
The [CryptoProvider] passed to the callback should be used for all cryptographic operations.
§Example
This example implements the behavior of Self::embedded via Self::custom_server_cert_verifier.
let tls_config = CaTlsConfig::custom_server_cert_verifier(Arc::new(move |crypto_provider| {
let root_store = Arc::new(rustls::RootCertStore {
roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(),
});
let verifier = WebPkiServerVerifier::builder_with_provider(root_store, crypto_provider)
.build()
.map_err(io::Error::other)?;
Ok(verifier)
}));Sourcepub fn with_extra_roots(
self,
extra_roots: impl IntoIterator<Item = CertificateDer<'static>>,
) -> Self
pub fn with_extra_roots( self, extra_roots: impl IntoIterator<Item = CertificateDer<'static>>, ) -> Self
Adds additional root certificates to the list of trusted certificates.
Ignored when using Self::custom_server_cert_verifier.
Sourcepub fn server_cert_verifier(
&self,
crypto_provider: Arc<CryptoProvider>,
) -> Result<Arc<dyn ServerCertVerifier>>
pub fn server_cert_verifier( &self, crypto_provider: Arc<CryptoProvider>, ) -> Result<Arc<dyn ServerCertVerifier>>
Builds a [ServerCertVerifier] from this config.
Sourcepub fn client_config(
&self,
crypto_provider: Arc<CryptoProvider>,
) -> Result<ClientConfig>
pub fn client_config( &self, crypto_provider: Arc<CryptoProvider>, ) -> Result<ClientConfig>
Builds a [ClientConfig] from this config.
Trait Implementations§
Source§impl Clone for CaTlsConfig
impl Clone for CaTlsConfig
Source§fn clone(&self) -> CaTlsConfig
fn clone(&self) -> CaTlsConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CaTlsConfig
impl Debug for CaTlsConfig
Auto Trait Implementations§
impl Freeze for CaTlsConfig
impl !RefUnwindSafe for CaTlsConfig
impl Send for CaTlsConfig
impl Sync for CaTlsConfig
impl Unpin for CaTlsConfig
impl !UnwindSafe for CaTlsConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more