diff --git a/iReSign.app/Contents/MacOS/iReSign b/iReSign.app/Contents/MacOS/iReSign index 55bdbdd..f359547 100755 Binary files a/iReSign.app/Contents/MacOS/iReSign and b/iReSign.app/Contents/MacOS/iReSign differ diff --git a/iReSign/iReSign/iReSignAppDelegate.m b/iReSign/iReSign/iReSignAppDelegate.m index d536f4e..b7df637 100755 --- a/iReSign/iReSign/iReSignAppDelegate.m +++ b/iReSign/iReSign/iReSignAppDelegate.m @@ -21,6 +21,13 @@ static NSString *kInfoPlistFilename = @"Info.plist"; static NSString *kiTunesMetadataFileName = @"iTunesMetadata"; + +@interface iReSignAppDelegate() +@property (nonatomic , strong) NSDictionary* signinigCerts; +@end + + + @implementation iReSignAppDelegate @synthesize window,workingPath; @@ -372,22 +379,22 @@ - (void)doEntitlementsFixing } [statusLabel setStringValue:@"Generating entitlements"]; - + if (appPath) { generateEntitlementsTask = [[NSTask alloc] init]; [generateEntitlementsTask setLaunchPath:@"/usr/bin/security"]; [generateEntitlementsTask setArguments:@[@"cms", @"-D", @"-i", provisioningPathField.stringValue]]; [generateEntitlementsTask setCurrentDirectoryPath:workingPath]; - + [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkEntitlementsFix:) userInfo:nil repeats:TRUE]; - + NSPipe *pipe=[NSPipe pipe]; [generateEntitlementsTask setStandardOutput:pipe]; [generateEntitlementsTask setStandardError:pipe]; NSFileHandle *handle = [pipe fileHandleForReading]; - + [generateEntitlementsTask launch]; - + [NSThread detachNewThreadSelector:@selector(watchEntitlements:) toTarget:self withObject:handle]; } @@ -473,7 +480,9 @@ - (void)signFile:(NSString*)filePath { NSLog(@"Codesigning %@", filePath); [statusLabel setStringValue:[NSString stringWithFormat:@"Codesigning %@",filePath]]; - NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", [certComboBox objectValue], nil]; + NSString* certHash = [self.signinigCerts objectForKey:[certComboBox objectValue]] ? [self.signinigCerts objectForKey:[certComboBox objectValue]] : [certComboBox objectValue]; + + NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", certHash, nil]; NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; NSString * systemVersion = [systemVersionDictionary objectForKey:@"ProductVersion"]; NSArray * version = [systemVersion componentsSeparatedByString:@"."]; @@ -558,7 +567,7 @@ - (void)doVerifySignature { verifyTask = [[NSTask alloc] init]; [verifyTask setLaunchPath:@"/usr/bin/codesign"]; [verifyTask setArguments:[NSArray arrayWithObjects:@"-v", appPath, nil]]; - + [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkVerificationProcess:) userInfo:nil repeats:TRUE]; NSLog(@"Verifying %@",appPath); @@ -623,7 +632,7 @@ - (void)doZip { [zipTask setLaunchPath:@"/usr/bin/zip"]; [zipTask setCurrentDirectoryPath:workingPath]; [zipTask setArguments:[NSArray arrayWithObjects:@"-qry", destinationPath, @".", nil]]; - + [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkZip:) userInfo:nil repeats:TRUE]; NSLog(@"Zipping %@", destinationPath); @@ -784,20 +793,28 @@ - (void)watchGetCerts:(NSFileHandle*)streamHandle { // Nothing in the result, return return; } - NSArray *rawResult = [securityResult componentsSeparatedByString:@"\""]; - NSMutableArray *tempGetCertsResult = [NSMutableArray arrayWithCapacity:20]; - for (int i = 0; i <= [rawResult count] - 2; i+=2) { + NSArray *rawResult = [securityResult componentsSeparatedByString:@"\n"]; + NSMutableDictionary *tempGetCertsResult = [NSMutableDictionary dictionaryWithCapacity:20]; + NSMutableArray *tempGetCertsResultNames = [NSMutableArray arrayWithCapacity:20]; + for (int i = 0; i < [rawResult count] - 2; i++) { + if(!rawResult || [[rawResult objectAtIndex:i] isEqualToString:@""]) continue; - NSLog(@"i:%d", i+1); - if (rawResult.count - 1 < i + 1) { + NSArray *row = [[[rawResult objectAtIndex:i] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsSeparatedByString:@" "]; + if (row.count < 3) + { // Invalid array, don't add an object to that position } else { // Valid object - [tempGetCertsResult addObject:[rawResult objectAtIndex:i+1]]; + + NSString* name = [[[rawResult objectAtIndex:i] componentsSeparatedByString:@"\""] objectAtIndex:1]; + [tempGetCertsResult setObject:[row objectAtIndex:1] forKey:name]; + [tempGetCertsResultNames addObject:name]; } } - certComboBoxItems = [NSMutableArray arrayWithArray:tempGetCertsResult]; + + self.signinigCerts = tempGetCertsResult; + certComboBoxItems = [NSMutableArray arrayWithArray:tempGetCertsResultNames]; [certComboBox reloadData]; @@ -859,3 +876,6 @@ - (void)showAlertOfKind:(NSAlertStyle)style WithTitle:(NSString *)title AndMessa } @end + + +