More verbose error message when DSA keys don't match

This commit is contained in:
Kornel Lesiński committed 2015-07-01 00:30:35 +01:00
1 parent dc1cd3a259
commit efdf9d4421
1 file changed
+17 -9
+17 -9
View File
@@ -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;
}