ICE: trust the system certificate store for TURN over TLS

A TLS-inspecting HTTP proxy re-signs the TURN certificate with a CA that the
host's administrator installed in the system store; OpenSSL accepts it while
the bundled Mozilla roots alone fail with UnknownIssuer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
VallierDevandClaude Opus 5.5 committed 2026-10-28 20:21:37 +08:00
1 parent 5656f33d86
commit 64d2ffbdd3
4 files changed
+10

No files matched your search

Generated
+1
View File
@@ -3016,6 +3016,7 @@ dependencies = [
"crc",
"log",
"rand 0.8.8",
"rustls-native-certs",
"serde",
"serde_json",
"stun",
+3
View File
@@ -45,6 +45,9 @@ package = "webrtc-mdns"
[dependencies.rand]
version = "0.8"
[dependencies.rustls-native-certs]
version = "0.8"
[dependencies.serde]
version = "1"
features = ["derive"]
+3
View File
@@ -11,3 +11,6 @@ the TURN servers but whose TCP goes through an HTTP proxy.
application with `set_relay_transport`), adds TLS for `turns:`, and exposes the stream to the
unchanged `turn` client as datagrams: one STUN message or ChannelData frame (with its 4-byte TCP
padding) per read. `agent_gather.rs` uses it for `ProtoType::Tcp` URLs. UDP gathering is unchanged.
TLS trusts the system certificate store (`rustls-native-certs`, as OpenSSL does) plus the bundled
Mozilla roots. A name mismatch is accepted only when the TURN URL is an IP literal.
+3
View File
@@ -86,7 +86,10 @@ async fn tls_connect(tcp: TcpStream, host: &str)
-> Result<tokio_rustls::client::TlsStream<TcpStream>, String> {
use tokio_rustls::rustls::{self, client::WebPkiServerVerifier, pki_types::ServerName};
let provider = Arc::new(rustls::crypto::ring::default_provider());
// System store first (it holds any CA the host's administrator added, e.g. for a TLS-inspecting
// proxy, as OpenSSL would use), then the bundled Mozilla roots.
let mut roots = rustls::RootCertStore::empty();
roots.add_parsable_certificates(rustls_native_certs::load_native_certs().certs);
roots.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
let inner = WebPkiServerVerifier::builder_with_provider(Arc::new(roots), provider.clone()).build()
.map_err(|e| format!("TURN TLS setup: {e}"))?;