Skip to content

feat: allow to customize TLS trust roots#3973

Merged
Frando merged 18 commits intomainfrom
Frando/customize-tls
Feb 27, 2026
Merged

feat: allow to customize TLS trust roots#3973
Frando merged 18 commits intomainfrom
Frando/customize-tls

Conversation

@Frando
Copy link
Copy Markdown
Member

@Frando Frando commented Feb 25, 2026

Description

This adds customization to how certificates for non-iroh TLS connections are verified. It adds a new CaRootsConfig struct which provides these options:

  • Embedded WebPki roots (like currently), with optional extra roots
  • Operating system's roots, with optional extra roots
  • Custom list of roots only
  • No verification (gated behind test-utils feature, like now)

This struct can be built into a rustls::ClientConfig, which is then used for:

  • Connecting to relays, both HTTPS probes, QAD, and actual WebSocket connections
  • Connecting to pkarr servers
  • In the DNS resolver, if DNS-over-HTTPS is configured

I think that's all places where we use TLS connections in iroh. Will have another look if we missed any.

Breaking Changes

Removed:

  • iroh::endpoint::Builder::insecure_skip_cert_verify, use Builder::ca_roots_config(CaRootsConfig::insecure_skip_verify()) instead
  • iroh_relay::client::ClientBuilder::insecure_skip_cert_verify, remove ClientBuilder::tls_client_config instead
  • iroh::address_lookup::pkarr::PkarrResolverBuilder::build and iroh::address_lookup::pkarr::PkarrPublisherBuilder::build now take a tls_config: rustls::ClientConfig arg. If building via Endpoint::add_discovery or endpoint::Builder::discovery no change is needed since the TLS config is passed from the endpoint builder. If constructing manually for some reason, either pass Endpoint::tls_config or construct a TLS config yourself, e.g. via iroh::tls::CaRootsConfig::client_config.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 25, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3973/docs/iroh/

Last updated: 2026-02-27T10:47:49Z

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 25, 2026

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: f56c4cd

@Frando
Copy link
Copy Markdown
Member Author

Frando commented Feb 25, 2026

Interesting: I switched the default to use the operating system's defaults, and tests fail on windows and android. Will have a closer look soon. But maybe we should stay with embedded WebPKI as default then.

Edit: Windows fails the integration test with
2026-02-25T13:27:49.7969117Z 2026-02-25T13:27:38.015343Z WARN actor:reportgen-actor:run-probe{proto=Https delay=200ms relay=RelayConfig { url: RelayUrl("https://staging-euw1-1.relay.iroh.network./"), quic: Some(RelayQuicConfig { port: 7842 }) }}: iroh::net_report::reportgen: probe failed: Failed to run HTTPS probe: HTTP request failed: error sending request for url (https://staging-euw1-1.relay.iroh.network./ping): client error (Connect): invalid peer certificate: NotValidForName
i.e. it seems there's no host certs, or they are somehow not trusting our cert?

@n0bot n0bot bot added this to iroh Feb 25, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Feb 25, 2026
@Frando
Copy link
Copy Markdown
Member Author

Frando commented Feb 25, 2026

I switched the default back to the embedded roots.

///
/// If *keylog* is `true` then setting the `SSLKEYLOGFILE` environment variable to a
/// filename will result in this file being used to log the TLS pre-master keys.
pub fn keylog(mut self, keylog: bool) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an option on the webtlsconfig?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this setting is about TLS config for iroh connections, not WebTls

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add this to WebTlsConfig as well. Currently WebTls doesn't ever have resumption configured. Do we? Don't think there's any 0RTT though for our web uses

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is out-of-scope for CaRootsConfig (now that we've renamed it that's maybe clearer).
Making keylog effect TLS connections other than the iroh ones is perhaps another issue/PR.

/// number of clients.
///
/// The default is 256, taking about 150 KiB in memory.
pub fn max_tls_tickets(mut self, n: usize) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about these other tls options?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO they're out-of-scope for the current CaRootsConfig.

Maybe in the future we group CaRootsConfig and friends into a TlsConfig down the line, but IMO that's another PR.

(Also TLS tickets are probably only relevant to iroh connections)

@Frando Frando marked this pull request as ready for review February 26, 2026 12:37
Copy link
Copy Markdown
Member

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this land. Not sure if this should be 0.97 or 0.98.

Comment on lines +22 to +23
#[derive(Debug, Clone)]
enum Mode {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally not sure we need to duplicate the docs on this struct now.

Copy link
Copy Markdown
Member

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, thank you!

@Frando Frando enabled auto-merge February 27, 2026 10:32
@Frando Frando disabled auto-merge February 27, 2026 10:33
@Frando Frando enabled auto-merge February 27, 2026 10:48
@Frando Frando added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit ba4ee62 Feb 27, 2026
28 of 29 checks passed
@github-project-automation github-project-automation bot moved this from 🚑 Needs Triage to ✅ Done in iroh Feb 27, 2026
@matheus23 matheus23 deleted the Frando/customize-tls branch February 27, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants