@@ -11,8 +11,8 @@ use crate::api::{
1111use base64:: decode;
1212use http:: StatusCode ;
1313use minisign_verify:: { PublicKey , Signature } ;
14- use tauri_utils:: Env ;
1514use tauri_utils:: platform:: current_exe;
15+ use tauri_utils:: Env ;
1616
1717use std:: {
1818 collections:: HashMap ,
@@ -405,7 +405,7 @@ pub struct Update {
405405impl Update {
406406 // Download and install our update
407407 // @todo(lemarier): Split into download and install (two step) but need to be thread safe
408- pub async fn download_and_install ( & self , pub_key : Option < String > ) -> Result {
408+ pub async fn download_and_install ( & self , pub_key : String ) -> Result {
409409 // download url for selected release
410410 let url = self . download_url . as_str ( ) ;
411411 // extract path
@@ -453,18 +453,15 @@ impl Update {
453453 // create memory buffer from our archive (Seek + Read)
454454 let mut archive_buffer = Cursor :: new ( resp. data ) ;
455455
456- // Validate signature ONLY if pubkey is available in tauri.conf.json
457- if let Some ( pub_key) = pub_key {
458- // We need an announced signature by the server
459- // if there is no signature, bail out.
460- if let Some ( signature) = & self . signature {
461- // we make sure the archive is valid and signed with the private key linked with the publickey
462- verify_signature ( & mut archive_buffer, signature, & pub_key) ?;
463- } else {
464- // We have a public key inside our source file, but not announced by the server,
465- // we assume this update is NOT valid.
466- return Err ( Error :: PubkeyButNoSignature ) ;
467- }
456+ // We need an announced signature by the server
457+ // if there is no signature, bail out.
458+ if let Some ( signature) = & self . signature {
459+ // we make sure the archive is valid and signed with the private key linked with the publickey
460+ verify_signature ( & mut archive_buffer, signature, & pub_key) ?;
461+ } else {
462+ // We have a public key inside our source file, but not announced by the server,
463+ // we assume this update is NOT valid.
464+ return Err ( Error :: MissingUpdaterSignature ) ;
468465 }
469466
470467 // we copy the files depending of the operating system
@@ -1174,7 +1171,7 @@ mod test {
11741171 assert_eq ! ( updater. version, "2.0.1" ) ;
11751172
11761173 // download, install and validate signature
1177- let install_process = block ! ( updater. download_and_install( Some ( pubkey) ) ) ;
1174+ let install_process = block ! ( updater. download_and_install( pubkey) ) ;
11781175 assert ! ( install_process. is_ok( ) ) ;
11791176
11801177 // make sure the extraction went well (it should have skipped the main app.app folder)
0 commit comments