From efdf9d44219eb0a5ef8681d928cc813f4a12f21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Tue, 30 Jun 2015 23:58:38 +0100 Subject: [PATCH 1/3] More verbose error message when DSA keys don't match --- Sparkle/SUBasicUpdateDriver.m | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index b20efe51..d36a3885 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -258,33 +258,41 @@ SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; NSString *newPublicDSAKey = newHost.publicDSAKey; + BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + if (newPublicDSAKey != nil) { if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { - SULog(@"DSA signature validation failed. The update will be rejected."); + 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 || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath]; + if (dsaKeysMatch) { NSError *error = nil; - 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); + if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { + SULog(@"The update has a valid DSA signature, but it's also signed with Apple Code Signing, which is corrupted: %@. The update will be rejected.", error); return NO; } } else { - if (![SUCodeSigningVerifier hostApplicationIsCodeSigned] || ![SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath]) { - SULog(@"Public DSA keys differ or are absent, and both apps are not code signed. The update will be rejected."); + BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned]; + + NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key"); + if (!hostIsCodeSigned || !updateIsCodeSigned) { + NSString *acsStatus = hostIsCodeSigned ? @"old app hasn't been signed with Apple Code Signing" : @"update isn't signed with Apple Code Signing"; + SULog(@"The update %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); return NO; } - + NSError *error = nil; if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) { - SULog(@"The update will be rejected because the code signature from the original and updated application failed to match: %@", error); + SULog(@"The update %@, and is signed with a new Apple Code Signing identity that doesn't match code signing of the original application: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error); return NO; } } - + return YES; } From 99dedafc6796bd95865aafb5bd973efef92dbcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Wed, 1 Jul 2015 09:54:46 +0100 Subject: [PATCH 2/3] Fixed condition --- Sparkle/SUBasicUpdateDriver.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index d36a3885..f4899796 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -281,7 +281,7 @@ NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key"); if (!hostIsCodeSigned || !updateIsCodeSigned) { - NSString *acsStatus = hostIsCodeSigned ? @"old app hasn't been signed with Apple Code Signing" : @"update isn't signed with Apple Code Signing"; + NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with Apple Code Signing" : @"update isn't signed with Apple Code Signing"; SULog(@"The update %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); return NO; } From 33ef8ca2b45fc8169dfa32349ea2f27bddba1288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 5 Jul 2015 12:44:45 +0100 Subject: [PATCH 3/3] Clarify that DSA is for archives and Apple Code Signing is for apps --- README.markdown | 2 +- Sparkle/SUBasicUpdateDriver.m | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 0e557c53..8eaf4a34 100644 --- a/README.markdown +++ b/README.markdown @@ -19,7 +19,7 @@ An easy-to-use software update framework for Cocoa developers. * True self-updating—the user can choose to automatically download and install all updates. * Displays a detailed progress window to the user. * Supports authentication for installing in secure locations. -* Supports Apple code signing and DSA signatures for ultra-secure updates. +* Supports Apple Code Signing and DSA signatures for ultra-secure updates. * Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework. * Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites. * Displays release notes to the user via WebKit. diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index f4899796..d6f72f53 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -273,7 +273,7 @@ if (dsaKeysMatch) { NSError *error = nil; if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { - SULog(@"The update has a valid DSA signature, but it's also signed with Apple Code Signing, which is corrupted: %@. The update will be rejected.", error); + SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error); return NO; } } else { @@ -281,14 +281,14 @@ NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key"); if (!hostIsCodeSigned || !updateIsCodeSigned) { - NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with Apple Code Signing" : @"update isn't signed with Apple Code Signing"; - SULog(@"The update %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); + NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing"; + SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); return NO; } NSError *error = nil; if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) { - SULog(@"The update %@, and is signed with a new Apple Code Signing identity that doesn't match code signing of the original application: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error); + SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error); return NO; } }