Skip to content

Commit d398457

Browse files
Shivam60Copilot
andauthored
rust: use native-tls for the build-time CLI download (#1964)
build/in_process.rs and build/out_of_process.rs download the Copilot CLI with ureq, which was on the rustls (tls) feature and pulled rustls and ring into the build. Switch ureq to native-tls and build the connector in both download paths so the build no longer compiles rustls/ring (schannel on Windows, Security.framework on macOS, OpenSSL on Linux). Co-authored-by: Shivam Chawla <13963817+Shivam60@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ee7db7b commit d398457

4 files changed

Lines changed: 14 additions & 24 deletions

File tree

rust/Cargo.lock

Lines changed: 2 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@ flate2 = "1"
9797
serde_json = "1"
9898
sha2 = "0.10"
9999
tar = "0.4"
100-
ureq = { version = "2", default-features = false, features = ["tls"] }
100+
ureq = { version = "2", default-features = false, features = ["native-tls"] }
101+
native-tls = "0.2"
101102
zip = { version = "2", default-features = false, features = ["deflate"] }

rust/build/in_process.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,12 @@ struct DownloadError {
631631
}
632632

633633
fn try_download(url: &str) -> Result<Vec<u8>, DownloadError> {
634+
let connector = native_tls::TlsConnector::new().map_err(|e| DownloadError {
635+
message: format!("native-tls init error: {e}"),
636+
transient: false,
637+
})?;
634638
let agent = ureq::AgentBuilder::new()
639+
.tls_connector(std::sync::Arc::new(connector))
635640
.timeout_connect(Duration::from_secs(30))
636641
.timeout_read(Duration::from_secs(120))
637642
.build();

rust/build/out_of_process.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,12 @@ struct DownloadError {
599599
}
600600

601601
fn try_download(url: &str) -> Result<Vec<u8>, DownloadError> {
602+
let connector = native_tls::TlsConnector::new().map_err(|e| DownloadError {
603+
message: format!("native-tls init error: {e}"),
604+
transient: false,
605+
})?;
602606
let agent = ureq::AgentBuilder::new()
607+
.tls_connector(std::sync::Arc::new(connector))
603608
.timeout_connect(Duration::from_secs(30))
604609
.timeout_read(Duration::from_secs(120))
605610
.build();

0 commit comments

Comments
 (0)