Skip to content

Commit d81266a

Browse files
authored
Configure ureq to use platform-verifier for web assets (#20825)
# Objective - Fixes #20803 - See issue for motivations on this change ## Solution - Use ureq's `platform-verifier` feature and enable it in the agent config. I've gone the simple route and made this non-configurable, for now at least. The downside of this change is that you can longer use webpki-roots but if bevy only supports one certificate verification method then I think platform-verifier is the more sensible option. ## Testing - Tested the web_asset example on Windows and macOS
1 parent 42d41e3 commit d81266a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

crates/bevy_asset/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ file_watcher = ["notify-debouncer-full", "watch", "multi_threaded"]
1515
embedded_watcher = ["file_watcher"]
1616
multi_threaded = ["bevy_tasks/multi_threaded"]
1717
http = ["blocking", "ureq"]
18-
https = ["blocking", "ureq", "ureq/rustls"]
18+
https = ["blocking", "ureq", "ureq/rustls", "ureq/platform-verifier"]
1919
web_asset_cache = []
2020
asset_processor = []
2121
watch = []

crates/bevy_asset/src/io/web.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,19 @@ async fn get(path: PathBuf) -> Result<Box<dyn Reader>, AssetReaderError> {
138138
if let Some(data) = web_asset_cache::try_load_from_cache(str_path).await? {
139139
return Ok(Box::new(VecReader::new(data)));
140140
}
141+
use ureq::tls::{RootCerts, TlsConfig};
141142
use ureq::Agent;
142143

143-
static AGENT: LazyLock<Agent> = LazyLock::new(|| Agent::config_builder().build().new_agent());
144+
static AGENT: LazyLock<Agent> = LazyLock::new(|| {
145+
Agent::config_builder()
146+
.tls_config(
147+
TlsConfig::builder()
148+
.root_certs(RootCerts::PlatformVerifier)
149+
.build(),
150+
)
151+
.build()
152+
.new_agent()
153+
});
144154

145155
let uri = str_path.to_owned();
146156
// Use [`unblock`] to run the http request on a separately spawned thread as to not block bevy's

0 commit comments

Comments
 (0)