Struct CaTlsConfig
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§
§impl CaTlsConfig
impl CaTlsConfig
pub fn embedded() -> CaTlsConfig
pub fn embedded() -> CaTlsConfig
Uses a compiled-in copy of the root certificates trusted by Mozilla.
See [webpki_roots] for details.
pub fn custom_roots(
roots: impl IntoIterator<Item = CertificateDer<'static>>,
) -> CaTlsConfig
pub fn custom_roots( roots: impl IntoIterator<Item = CertificateDer<'static>>, ) -> CaTlsConfig
Only trusts the explicitly set root certificates.
pub fn custom(
roots: impl IntoIterator<Item = CertificateDer<'static>>,
) -> CaTlsConfig
👎Deprecated since 1.0.0: Renamed to custom_roots
pub fn custom( roots: impl IntoIterator<Item = CertificateDer<'static>>, ) -> CaTlsConfig
Renamed to custom_roots
Renamed to Self::custom_roots.
pub fn custom_server_cert_verifier(
builder: Arc<dyn Fn(Arc<CryptoProvider>) -> Result<Arc<dyn ServerCertVerifier>, Error> + Send + Sync>,
) -> CaTlsConfig
pub fn custom_server_cert_verifier( builder: Arc<dyn Fn(Arc<CryptoProvider>) -> Result<Arc<dyn ServerCertVerifier>, Error> + Send + Sync>, ) -> CaTlsConfig
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)
}));pub fn with_extra_roots(
self,
extra_roots: impl IntoIterator<Item = CertificateDer<'static>>,
) -> CaTlsConfig
pub fn with_extra_roots( self, extra_roots: impl IntoIterator<Item = CertificateDer<'static>>, ) -> CaTlsConfig
Adds additional root certificates to the list of trusted certificates.
Ignored when using Self::custom_server_cert_verifier.
pub fn server_cert_verifier(
&self,
crypto_provider: Arc<CryptoProvider>,
) -> Result<Arc<dyn ServerCertVerifier>, Error>
pub fn server_cert_verifier( &self, crypto_provider: Arc<CryptoProvider>, ) -> Result<Arc<dyn ServerCertVerifier>, Error>
Builds a [ServerCertVerifier] from this config.
pub fn client_config(
&self,
crypto_provider: Arc<CryptoProvider>,
) -> Result<ClientConfig, Error>
pub fn client_config( &self, crypto_provider: Arc<CryptoProvider>, ) -> Result<ClientConfig, Error>
Builds a [ClientConfig] from this config.
Trait Implementations§
§impl Clone for CaTlsConfig
impl Clone for CaTlsConfig
§fn clone(&self) -> CaTlsConfig
fn clone(&self) -> CaTlsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for CaTlsConfig
impl Debug for CaTlsConfig
§impl Default for CaTlsConfig
impl Default for CaTlsConfig
§fn default() -> CaTlsConfig
fn default() -> CaTlsConfig
Auto Trait Implementations§
impl !RefUnwindSafe for CaTlsConfig
impl !UnwindSafe for CaTlsConfig
impl Freeze for CaTlsConfig
impl Send for CaTlsConfig
impl Sync for CaTlsConfig
impl Unpin for CaTlsConfig
impl UnsafeUnpin for CaTlsConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more