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 authored and Kornel Lesiński committed 2014-06-28 23:26:12 +01:00
1 parent 06a897ed03
commit 98e5959461
1 file changed
+30 -1
+30 -1
View File
@@ -46,7 +46,19 @@
}
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);
@@ -55,6 +67,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
{
OSStatus result;