If the downloaded update fails the code signing check, log out some more detailed information to help with diagnosing the problem.

This commit is contained in:
Sam Deane committed 2014-06-17 15:27:44 +01:00
1 parent f832c27bf9
commit 779599b40d
1 file changed
+30 -1
+30 -1
View File
@@ -57,7 +57,19 @@ extern OSStatus SecStaticCodeCheckValidityWithErrors(SecStaticCodeRef staticCode
}
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error);
if (result != 0 && error) [*error autorelease];
if (result != 0 && error) {
if (result == errSecCSReqFailed) {
CFStringRef requirementString = nil;
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr)
SULog(@"Failed requirement %@", requirementString);
CFRelease(requirementString);
[self logSigningInfoForCode:hostCode label:@"host info"];
[self logSigningInfoForCode:staticCode label:@"new info"];
}
[*error autorelease];
}
finally:
if (hostCode) CFRelease(hostCode);
@@ -66,6 +78,23 @@ finally:
return (result == 0);
}
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
CFDictionaryRef signingInfo = nil;
const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation;
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
NSDictionary* signingDict = (NSDictionary*)signingInfo;
NSArray* keys = @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"];
NSMutableDictionary* relevantInfo = [NSMutableDictionary new];
for (NSString* key in keys)
relevantInfo[key] = signingDict[key];
NSDictionary* infoPlist = signingDict[@"info-plist"];
relevantInfo[@"version"] = infoPlist[@"CFBundleShortVersionString"];
relevantInfo[@"build"] = infoPlist[@"CFBundleVersion"];
CFRelease(signingInfo);
SULog(@"%@: %@", label, relevantInfo);
}
}
+ (BOOL)hostApplicationIsCodeSigned
{
// This API didn't exist prior to 10.6.