Skip to content

feat(bundler/cli): Add feature flag to use system certificates - #11

Open
tomerqodo wants to merge 2 commits into
coderabbit_full_base_featbundler_cli_add_feature_flag_to_use_system_certificates_pr11from
coderabbit_full_head_featbundler_cli_add_feature_flag_to_use_system_certificates_pr11
Open

feat(bundler/cli): Add feature flag to use system certificates#11
tomerqodo wants to merge 2 commits into
coderabbit_full_base_featbundler_cli_add_feature_flag_to_use_system_certificates_pr11from
coderabbit_full_head_featbundler_cli_add_feature_flag_to_use_system_certificates_pr11

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 30, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#11

Summary by CodeRabbit

  • New Features
    • The bundler and CLI now support using system TLS certificates when downloading tools and checking package versions, improving compatibility with enterprise environments and custom certificate configurations.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces platform certificate support for tauri-bundler and tauri-cli, enabling these tools to utilize the system's native TLS certificate store when downloading and verifying tools and versions. A new platform-certs feature is added across both crates, with HTTP utilities refactored to support conditional TLS configuration.

Changes

Cohort / File(s) Summary
Feature Declarations
crates/tauri-bundler/Cargo.toml, crates/tauri-cli/Cargo.toml
Added platform-certs feature that depends on ureq/platform-verifier and tauri-bundler/platform-certs. Updated default features to include platform-certs alongside rustls.
HTTP Utilities Refactoring
crates/tauri-bundler/src/utils/http_utils.rs
Introduced base_ureq_agent() helper to centralize HTTP agent construction with conditional TLS configuration for platform certificates. Refactored create_agent_and_url() to use the new helper and removed URL mutation in mirror base handling.
Windows Bundle Utilities
crates/tauri-bundler/src/bundle/windows/util.rs
Updated webview2 download logic to use base_ureq_agent() instead of per-call agent construction. Replaced direct download pattern with explicit HTTP requests and manual body reading for consistency with refactored HTTP utilities.
Cargo Manifest TLS Integration
crates/tauri-cli/src/helpers/cargo_manifest.rs
Added conditional TLS configuration in crate_latest_version() to use platform-root-certs verifier when platform-certs feature is enabled. Fixed crate_version() condition for lock_version population.
Changelog
.changes/feat-bundler-platform-certs.md
Added changelog entry documenting minor enhancements for system TLS certificate reading across bundler and CLI tools.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as tauri-cli/bundler
    participant Agent as HTTP Agent<br/>(ureq)
    participant TLS as TLS Verifier
    participant API as External API<br/>(crates.io, CDN)

    Note over CLI,API: With platform-certs feature enabled
    
    CLI->>Agent: Create base_ureq_agent()
    Agent->>TLS: Configure platform-root-certs
    TLS->>TLS: Load system certificate store
    CLI->>Agent: Make HTTP request
    Agent->>TLS: Validate certificate
    TLS->>API: Connection verified
    API-->>Agent: Response
    Agent-->>CLI: Data/File content

    Note over CLI,API: Without platform-certs feature
    
    CLI->>Agent: Create base_ureq_agent()
    Agent->>TLS: Use default proxy config
    CLI->>Agent: Make HTTP request
    Agent->>API: Standard TLS validation
    API-->>Agent: Response
    Agent-->>CLI: Data/File content
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops of joy through certificate halls,
Platform trust now answers our calls!
System roots bundled with care,
TLS verification beyond compare,
Secure downloads everywhere! 🔐

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a feature flag to enable system certificate usage in the bundler and CLI tools.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_featbundler_cli_add_feature_flag_to_use_system_certificates_pr11

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
crates/tauri-bundler/src/utils/http_utils.rs (1)

33-39: ⚠️ Potential issue | 🟠 Major

generate_github_mirror_url_from_base drops the asset path, breaking mirror downloads.

The function ignores its github_url parameter and returns only the base mirror URL (e.g., https://mirror.example.com/) without the asset path. When the template method is unavailable and this fallback is used, the download URL becomes incorrect. Attach the original GitHub URL's path and query to the mirror base.

🛠️ Proposed fix (preserve path/query)
 fn generate_github_mirror_url_from_base(github_url: &str) -> Option<String> {
+  let github = Url::parse(github_url).ok()?;
   std::env::var("TAURI_BUNDLER_TOOLS_GITHUB_MIRROR")
     .ok()
     .and_then(|cdn| Url::parse(&cdn).ok())
-    .map(|cdn| {
-      cdn.to_string()
-    })
+    .map(|mut cdn| {
+      cdn.set_path(github.path());
+      cdn.set_query(github.query());
+      cdn.to_string()
+    })
 }
crates/tauri-bundler/src/bundle/windows/util.rs (1)

54-69: ⚠️ Potential issue | 🟠 Major

Use base_ureq_agent() for WebView2 offline installer download.
Line 65 uses ureq::get(url) directly, which skips proxy and platform certificate configuration. This breaks downloads in corporate environments with proxies or custom CAs. Use base_ureq_agent() instead, consistent with webview2_guid_path() and download_webview2_bootstrapper() in this file.

Fix
-    let response = ureq::get(url).call().map_err(Box::new)?;
+    let response = base_ureq_agent().get(url).call().map_err(Box::new)?;
     let mut bytes = Vec::new();
🤖 Fix all issues with AI agents
In `@crates/tauri-bundler/src/utils/http_utils.rs`:
- Around line 52-72: The mirror-download path in generate_github_alternative_url
is creating its own agent with ureq::agent(), bypassing the proxy/TLS config;
change that to call base_ureq_agent() so mirror downloads reuse the same TLS
root-certs and proxy settings as regular downloads. Locate the
generate_github_alternative_url function and replace the ureq::agent()
construction with a call to base_ureq_agent(), ensuring the returned
(ureq::Agent, String) tuple uses that agent for the alternative URL path. Verify
no other code paths construct a plain ureq::agent() where base_ureq_agent()
should be used.

Comment on lines 52 to +72
fn create_agent_and_url(url: &str) -> (ureq::Agent, String) {
generate_github_alternative_url(url).unwrap_or((
ureq::Agent::config_builder()
.proxy(ureq::Proxy::try_from_env())
.build()
.into(),
url.to_owned(),
))
generate_github_alternative_url(url).unwrap_or((base_ureq_agent(), url.to_owned()))
}

pub(crate) fn base_ureq_agent() -> ureq::Agent {
#[cfg(feature = "platform-certs")]
let agent: ureq::Agent = ureq::Agent::config_builder()
.tls_config(
ureq::tls::TlsConfig::builder()
.root_certs(ureq::tls::RootCerts::PlatformVerifier)
.build(),
)
.proxy(ureq::Proxy::try_from_env())
.build()
.into();
#[cfg(not(feature = "platform-certs"))]
let agent: ureq::Agent = ureq::Agent::config_builder()
.proxy(ureq::Proxy::try_from_env())
.build()
.into();
return agent;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n crates/tauri-bundler/src/utils/http_utils.rs

Repository: agentic-review-benchmarks/tauri-combined-coderabbit

Length of output: 8184


Mirror downloads should reuse base_ureq_agent for TLS/proxy parity.

Line 49 in generate_github_alternative_url uses ureq::agent() instead of base_ureq_agent(), causing mirror downloads to bypass platform certificate verification and proxy configuration that apply to regular downloads. Change line 49 to use base_ureq_agent() to maintain consistent behavior across both code paths.

🔁 Proposed fix
-    .map(|alt_url| (ureq::agent(), alt_url))
+    .map(|alt_url| (base_ureq_agent(), alt_url))
🤖 Prompt for AI Agents
In `@crates/tauri-bundler/src/utils/http_utils.rs` around lines 52 - 72, The
mirror-download path in generate_github_alternative_url is creating its own
agent with ureq::agent(), bypassing the proxy/TLS config; change that to call
base_ureq_agent() so mirror downloads reuse the same TLS root-certs and proxy
settings as regular downloads. Locate the generate_github_alternative_url
function and replace the ureq::agent() construction with a call to
base_ureq_agent(), ensuring the returned (ureq::Agent, String) tuple uses that
agent for the alternative URL path. Verify no other code paths construct a plain
ureq::agent() where base_ureq_agent() should be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant