Skip to content

Commit a8f1569

Browse files
fix(windows): bundler should not sign non-binaries (#13921)
* fix(windows): bundler should not sign non-binaries * Fix non Windows
1 parent 0ea08e9 commit a8f1569

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri-bundler: "patch:bug"
3+
---
4+
5+
The bundler will no longer try to sign non-binary and already signed binary files on Windows

crates/tauri-bundler/src/bundle/windows/msi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
bundle::{
88
settings::{Arch, Settings},
99
windows::{
10-
sign::try_sign,
10+
sign::{should_sign, try_sign},
1111
util::{
1212
download_webview2_bootstrapper, download_webview2_offline_installer,
1313
WIX_OUTPUT_FOLDER_NAME, WIX_UPDATER_OUTPUT_FOLDER_NAME,
@@ -988,7 +988,7 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
988988
}
989989
added_resources.push(resource_path.clone());
990990

991-
if settings.can_sign() {
991+
if settings.can_sign() && should_sign(&resource_path)? {
992992
try_sign(&resource_path, settings)?;
993993
}
994994

crates/tauri-bundler/src/bundle/windows/nsis/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
bundle::{
77
settings::Arch,
88
windows::{
9-
sign::{sign_command, try_sign},
9+
sign::{should_sign, sign_command, try_sign},
1010
util::{
1111
download_webview2_bootstrapper, download_webview2_offline_installer,
1212
NSIS_OUTPUT_FOLDER_NAME, NSIS_UPDATER_OUTPUT_FOLDER_NAME,
@@ -743,7 +743,7 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourcesMap> {
743743
}
744744
added_resources.push(resource_path.clone());
745745

746-
if settings.can_sign() {
746+
if settings.can_sign() && should_sign(&resource_path)? {
747747
try_sign(&resource_path, settings)?;
748748
}
749749

crates/tauri-bundler/src/bundle/windows/sign.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,26 @@ pub fn try_sign<P: AsRef<Path>>(file_path: P, settings: &Settings) -> crate::Res
257257
}
258258
Ok(())
259259
}
260+
261+
/// If the file is signable (is a binary file) and not signed already
262+
/// (will skip the verification if not on Windows since we can't verify it)
263+
pub fn should_sign(file_path: &Path) -> crate::Result<bool> {
264+
let is_binary = file_path
265+
.extension()
266+
.and_then(|extension| extension.to_str())
267+
.is_some_and(|extension| matches!(extension, "exe" | "dll"));
268+
if !is_binary {
269+
return Ok(false);
270+
}
271+
272+
#[cfg(windows)]
273+
{
274+
let already_signed = verify(file_path)?;
275+
Ok(!already_signed)
276+
}
277+
// Skip verification if not on Windows since we can't verify it
278+
#[cfg(not(windows))]
279+
{
280+
Ok(true)
281+
}
282+
}

0 commit comments

Comments
 (0)