fix(session): pick the ring TLS provider before any TLS use
- both rustls providers are compiled in on Windows, rustls then panicked on the native Trouter connect - installed at app start, before the HTTP client and before each Trouter connect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -157,6 +157,7 @@ fn open_store(path: &std::path::Path) -> Store {
157
157
}
158
158
159
159
fn main() {
160
session::ensure_crypto_provider();
160
161
app_base::version::set_build_version(VERSION_MARKER.trim_start_matches("teams-build:"));
161
162
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {
162
163
app_base::version::set_release_tag(tag);
@@ -157,6 +157,7 @@ fn open_store(path: &std::path::Path) -> Store {157
}157
}158
158
159
fn main() {159
fn main() {160
session::ensure_crypto_provider();160
app_base::version::set_build_version(VERSION_MARKER.trim_start_matches("teams-build:"));161
app_base::version::set_build_version(VERSION_MARKER.trim_start_matches("teams-build:"));161
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {162
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {162
app_base::version::set_release_tag(tag);163
app_base::version::set_release_tag(tag);@@ -351,6 +351,7 @@ impl NativeTrouter {
351
351
return Err(None);
352
352
}
353
353
};
354
session::ensure_crypto_provider();
354
355
let url = socket_url(&self.host, &self.endpoint_id, &uuid::Uuid::new_v4().to_string(), now_ms() as u128);
355
356
let Ok(Ok((socket, _))) = timeout(CONNECT_TIMEOUT, connect_async(url.as_str())).await else {
356
357
self.forward(&status_payload("disconnected", "connect_failed"));
@@ -351,6 +351,7 @@ impl NativeTrouter {351
return Err(None);351
return Err(None);352
}352
}353
};353
};354
session::ensure_crypto_provider();354
let url = socket_url(&self.host, &self.endpoint_id, &uuid::Uuid::new_v4().to_string(), now_ms() as u128);355
let url = socket_url(&self.host, &self.endpoint_id, &uuid::Uuid::new_v4().to_string(), now_ms() as u128);355
let Ok(Ok((socket, _))) = timeout(CONNECT_TIMEOUT, connect_async(url.as_str())).await else {356
let Ok(Ok((socket, _))) = timeout(CONNECT_TIMEOUT, connect_async(url.as_str())).await else {356
self.forward(&status_payload("disconnected", "connect_failed"));357
self.forward(&status_payload("disconnected", "connect_failed"));@@ -9,6 +9,7 @@ publish.workspace = true
9
9
base64.workspace = true
10
10
futures-util.workspace = true
11
11
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }
12
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
12
13
serde.workspace = true
13
14
serde_json.workspace = true
14
15
thiserror.workspace = true
@@ -9,6 +9,7 @@ publish.workspace = true9
base64.workspace = true9
base64.workspace = true10
futures-util.workspace = true10
futures-util.workspace = true11
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }11
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }12
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }12
serde.workspace = true13
serde.workspace = true13
serde_json.workspace = true14
serde_json.workspace = true14
thiserror.workspace = true15
thiserror.workspace = true@@ -12,6 +12,7 @@ mod transport;
12
12
pub use app::{App, Target, find_app_tab, has_login_tab, is_login_url};
13
13
pub use error::{Error, Result};
14
14
pub use events::{TabChannel, TabCommand, TabControl, TabEvent, TabEvents};
15
pub use native::ensure_crypto_provider;
15
16
pub use page_script::token_acquirer_script;
16
17
pub use request::{ApiResponse, AugloopExchange, AugloopStage, BodyToken, Method, Request, SignalrExchange};
17
18
pub use scope::{GRAPH, IC3, NestedApp, OUTLOOK, PRESENCE, SPACES, Scope};
@@ -12,6 +12,7 @@ mod transport;12
pub use app::{App, Target, find_app_tab, has_login_tab, is_login_url};12
pub use app::{App, Target, find_app_tab, has_login_tab, is_login_url};13
pub use error::{Error, Result};13
pub use error::{Error, Result};14
pub use events::{TabChannel, TabCommand, TabControl, TabEvent, TabEvents};14
pub use events::{TabChannel, TabCommand, TabControl, TabEvent, TabEvents};15
pub use native::ensure_crypto_provider;15
pub use page_script::token_acquirer_script;16
pub use page_script::token_acquirer_script;16
pub use request::{ApiResponse, AugloopExchange, AugloopStage, BodyToken, Method, Request, SignalrExchange};17
pub use request::{ApiResponse, AugloopExchange, AugloopStage, BodyToken, Method, Request, SignalrExchange};17
pub use scope::{GRAPH, IC3, NestedApp, OUTLOOK, PRESENCE, SPACES, Scope};18
pub use scope::{GRAPH, IC3, NestedApp, OUTLOOK, PRESENCE, SPACES, Scope};@@ -47,6 +47,7 @@ pub(crate) struct NativeHttp {
47
47
48
48
impl NativeHttp {
49
49
pub(crate) fn new(timeout: Duration, max_bytes: u64) -> Option<Self> {
50
ensure_crypto_provider();
50
51
let client = reqwest::Client::builder().timeout(timeout).build().ok()?;
51
52
Some(NativeHttp { client, tokens: Mutex::new(HashMap::new()), max_bytes })
52
53
}
@@ -149,6 +150,13 @@ impl NativeHttp {
149
150
150
151
const TEAMS_BEARER_PATHS: [&str; 2] = ["/api/", "/registrar/"];
151
152
153
/// Both rustls providers end up compiled in through dependencies, and then rustls refuses to pick one on its own.
154
pub fn ensure_crypto_provider() {
155
if rustls::crypto::CryptoProvider::get_default().is_none() {
156
let _ = rustls::crypto::ring::default_provider().install_default();
157
}
158
}
159
152
160
/// Page-only: websocket exchanges, tokens spliced into bodies, and app-origin calls that may rely on its cookies.
153
161
fn eligible(request: &Request) -> bool {
154
162
request.signalr.is_none()
@@ -47,6 +47,7 @@ pub(crate) struct NativeHttp {47
47
48
impl NativeHttp {48
impl NativeHttp {49
pub(crate) fn new(timeout: Duration, max_bytes: u64) -> Option<Self> {49
pub(crate) fn new(timeout: Duration, max_bytes: u64) -> Option<Self> {50
ensure_crypto_provider();50
let client = reqwest::Client::builder().timeout(timeout).build().ok()?;51
let client = reqwest::Client::builder().timeout(timeout).build().ok()?;51
Some(NativeHttp { client, tokens: Mutex::new(HashMap::new()), max_bytes })52
Some(NativeHttp { client, tokens: Mutex::new(HashMap::new()), max_bytes })52
}53
}@@ -149,6 +150,13 @@ impl NativeHttp {149
150
150
const TEAMS_BEARER_PATHS: [&str; 2] = ["/api/", "/registrar/"];151
const TEAMS_BEARER_PATHS: [&str; 2] = ["/api/", "/registrar/"];151
152
153
/// Both rustls providers end up compiled in through dependencies, and then rustls refuses to pick one on its own.154
pub fn ensure_crypto_provider() {155
if rustls::crypto::CryptoProvider::get_default().is_none() {156
let _ = rustls::crypto::ring::default_provider().install_default();157
}158
}159
152
/// Page-only: websocket exchanges, tokens spliced into bodies, and app-origin calls that may rely on its cookies.160
/// Page-only: websocket exchanges, tokens spliced into bodies, and app-origin calls that may rely on its cookies.153
fn eligible(request: &Request) -> bool {161
fn eligible(request: &Request) -> bool {154
request.signalr.is_none()162
request.signalr.is_none()