Skip to content

Commit

Permalink
fix(bundler): try to sign binaries only if targeting windows (#11404)
Browse files Browse the repository at this point in the history
* fix(bundler): try to sign binaries only if targeting windows

closes #10505

* fmt
  • Loading branch information
amrbashir authored Oct 20, 2024
1 parent 7b0aac9 commit a5f045e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .changes/bundler-custom-command-sign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": "patch:bug"
"tauri-bundler": "patch:bug"
---

Fix bundler trying to sign binaries for Windows build when actually building for macOS or Linux.
51 changes: 27 additions & 24 deletions tooling/bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,36 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
}

if settings.can_sign() {
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
for bin in settings.binaries() {
let bin_path = settings.binary_path(bin);
windows::sign::try_sign(&bin_path, &settings)?;
}

// Sign the sidecar binaries
for bin in settings.external_binaries() {
let path = bin?;
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
if skip {
continue;
if target_os == "windows" {
if settings.can_sign() {
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
for bin in settings.binaries() {
let bin_path = settings.binary_path(bin);
windows::sign::try_sign(&bin_path, &settings)?;
}
#[cfg(windows)]
if windows::sign::verify(&path)? {
info!(
"sidecar at \"{}\" already signed. Skipping...",
path.display()
);
continue;

// Sign the sidecar binaries
for bin in settings.external_binaries() {
let path = bin?;
let skip =
std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
if skip {
continue;
}
#[cfg(windows)]
if windows::sign::verify(&path)? {
info!(
"sidecar at \"{}\" already signed. Skipping...",
path.display()
);
continue;
}
windows::sign::try_sign(&path, &settings)?;
}
windows::sign::try_sign(&path, &settings)?;
} else {
#[cfg(not(target_os = "windows"))]
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
}
} else {
#[cfg(not(target_os = "windows"))]
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
}

for package_type in &package_types {
Expand Down

0 comments on commit a5f045e

Please sign in to comment.