From b1d887264fc5782b83b466b78b145e844d6f7fac Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 5 Jun 2015 21:37:09 -0400 Subject: [PATCH] Fix package validation from previous commit Modern packages aren't distributed as bundles, and we wouldn't be able to obtain a "new" public DSA key from an update --- Sparkle/SUBasicUpdateDriver.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 1fd02a89..9ad5fcdc 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -228,6 +228,17 @@ return NO; } + // Modern packages are not distributed as bundles and are code signed differently than regular applications + if (isPackage) { + BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey]; + + if (!packageValidated) { + SULog(@"DSA signature validation failed. The update will be rejected."); + } + + return packageValidated; + } + NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath]; if (newBundle == nil) { SULog(@"No suitable bundle is found in the update. The update will be rejected."); @@ -252,16 +263,11 @@ BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; if (dsaKeysMatch) { NSError *error = nil; - if (!isPackage && [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath] && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { + if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath] && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { SULog(@"The application to update has an invalid code signature: %@. The update will be rejected.", error); return NO; } } else { - if (isPackage) { - SULog(@"Public DSA key in update differs from the current package. The update will be rejected."); - return NO; - } - if (![SUCodeSigningVerifier hostApplicationIsCodeSigned] || ![SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath]) { SULog(@"Pubic DSA keys differ and both apps are not code signed. The update will be rejected."); return NO;