diff --git a/Sparkle/Autoupdate/AppInstaller.m b/Sparkle/Autoupdate/AppInstaller.m index 14f39705..304b245e 100644 --- a/Sparkle/Autoupdate/AppInstaller.m +++ b/Sparkle/Autoupdate/AppInstaller.m @@ -160,13 +160,11 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; } /** - * If the update is a package, then it must be signed using DSA. No other verification is done. + * If the update is a package, then the download must be signed using DSA. No other verification is done. * - * If the update is a bundle, then it must meet any one of: - * - * * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or - * - * * old and new Code Signing identity are the same and valid + * If the update is a bundle, then the download must also be signed using DSA. + * However, a change of DSA public keys is allowed if the Apple Code Signing identities match and are valid. + * Likewise, a change of Apple Code Signing identities is allowed if the DSA public keys match and the update is valid. * */ #warning - This might be better part of SUInstaller protocol since validation between app & packages differ @@ -205,14 +203,17 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; NSString *newPublicDSAKey = newHost.publicDSAKey; - BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + if (newPublicDSAKey == nil) { + SULog(@"No public DSA key is found in the update. For security reasons, the update will be rejected."); + return NO; + } - if (newPublicDSAKey != nil) { - if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { - SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", - dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); - return NO; - } + BOOL dsaKeysMatch = (publicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + + if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { + SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", + dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); + return NO; } BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtPathIsCodeSigned:installSourcePath]; diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index aca8ffa0..502a5acf 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -147,24 +147,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification } BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil; - BOOL isAppBundle = [self.hostBundle.bundlePath.pathExtension.lowercaseString isEqualToString:@"app"]; - BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtPathIsCodeSigned:self.host.bundle.bundlePath]; - - BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"]; - if (!isAppBundle && !hasPublicDSAKey) { + if (!hasPublicDSAKey) { if (error != NULL) { *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information." }]; } return NO; - } else if (isAppBundle && !(hasPublicDSAKey || hostIsCodeSigned)) { - if (error != NULL) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, you need to code sign your application and/or sign your updates with a DSA key. See Sparkle's documentation for more information." }]; - } - return NO; - } else if (isAppBundle && !hasPublicDSAKey && !servingOverHttps) { - SULog(@"WARNING: Serving updates over HTTP without signing them with a DSA key is deprecated and may not be possible in a future release. Please serve your updates over https, or sign them with a DSA key, or do both. See Sparkle's documentation for more information."); } + BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"]; BOOL allowsArbitraryHTTPLoads = SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS; if (!allowsArbitraryHTTPLoads && !servingOverHttps) { if (error != NULL) {