Skip to content

Commit

Permalink
fix: fix tls not working on arm (#127) (#128)
Browse files Browse the repository at this point in the history
* fix: fix tls not working on arm (#127)

* Fix formatting

* add change file

---------

Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
jan-br and lucasfernog-crabnebula authored Jan 14, 2024
1 parent bffce40 commit 3b3ce76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/fix-download-macos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cargo-packager": patch
"@crabnebula/packager": patch
---

Fix file download not working on macOS and Windows (arm).
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions crates/packager/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,19 @@ pub fn target_triple() -> crate::Result<String> {

pub(crate) fn download(url: &str) -> crate::Result<Vec<u8>> {
tracing::info!("Downloading {}", url);

// This is required because ureq does not bind native-tls as the default TLS implementation when rustls is not available.
// See <https://github.com/crabnebula-dev/cargo-packager/issues/127>
#[cfg(feature = "native-tls")]
let agent = ureq::AgentBuilder::new()
.tls_connector(std::sync::Arc::new(
native_tls::TlsConnector::new().unwrap(),
))
.try_proxy_from_env(true)
.build();
#[cfg(not(feature = "native-tls"))]
let agent = ureq::AgentBuilder::new().try_proxy_from_env(true).build();

let response = agent.get(url).call().map_err(Box::new)?;
let mut bytes = Vec::new();
response.into_reader().read_to_end(&mut bytes)?;
Expand Down

0 comments on commit 3b3ce76

Please sign in to comment.