mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge branch 'better-code-signature-logging' into sketch
This commit is contained in:
commit
51e10eb445
1 file changed
+30
-1
+30
-1
@@ -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 setObject:[signingDict objectForKey:key] forKey:key];
|
||||
NSDictionary* infoPlist = signingDict[@"info-plist"];
|
||||
[relevantInfo setObject:[infoPlist objectForKey:@"CFBundleShortVersionString"] forKey:@"version"];
|
||||
[relevantInfo setObject:[infoPlist objectForKey:@"CFBundleVersion"] forKey:@"build"];
|
||||
CFRelease(signingInfo);
|
||||
SULog(@"%@: %@", label, relevantInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
{
|
||||
// This API didn't exist prior to 10.6.
|
||||
|
||||
Reference in new issue
Block a user