Skip to content

Commit c2567c5

Browse files
committed
Merge pull request maciekish#46 from adzellman/master
2 parents f0fa976 + e073f20 commit c2567c5

File tree

7 files changed

+104
-62
lines changed

7 files changed

+104
-62
lines changed

iReSign.app/Contents/Info.plist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>BuildMachineOSBuild</key>
6-
<string>14D136</string>
6+
<string>15A235d</string>
77
<key>CFBundleDevelopmentRegion</key>
88
<string>en</string>
99
<key>CFBundleExecutable</key>
@@ -27,17 +27,17 @@
2727
<key>DTCompiler</key>
2828
<string>com.apple.compilers.llvm.clang.1_0</string>
2929
<key>DTPlatformBuild</key>
30-
<string>6D2105</string>
30+
<string>6E35b</string>
3131
<key>DTPlatformVersion</key>
3232
<string>GM</string>
3333
<key>DTSDKBuild</key>
3434
<string>14D125</string>
3535
<key>DTSDKName</key>
3636
<string>macosx10.10</string>
3737
<key>DTXcode</key>
38-
<string>0632</string>
38+
<string>0640</string>
3939
<key>DTXcodeBuild</key>
40-
<string>6D2105</string>
40+
<string>6E35b</string>
4141
<key>LSApplicationCategoryType</key>
4242
<string>public.app-category.developer-tools</string>
4343
<key>LSMinimumSystemVersion</key>

iReSign.app/Contents/MacOS/iReSign

42.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

iReSign/iReSign/en.lproj/MainMenu.xib

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14D87h" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
33
<dependencies>
4-
<deployment defaultVersion="1060" identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
4+
<deployment identifier="macosx"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
66
</dependencies>
77
<objects>
88
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -11,7 +11,7 @@
1111
</connections>
1212
</customObject>
1313
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14-
<customObject id="-3" userLabel="Application"/>
14+
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
1515
<menu title="AMainMenu" systemMenu="main" id="29">
1616
<items>
1717
<menuItem title="iReSign" id="56">
@@ -252,15 +252,15 @@
252252
<autoresizingMask key="autoresizingMask"/>
253253
<subviews>
254254
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="OGH-jD-zcO">
255-
<rect key="frame" x="20" y="190.0000008638354" width="69" height="69"/>
255+
<rect key="frame" x="20" y="190.0000017943762" width="69" height="69"/>
256256
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
257257
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Icon" id="LSY-JN-rDx"/>
258258
</imageView>
259259
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Ft3-WI-tTm">
260-
<rect key="frame" x="101.00000067379159" y="239.0000008638354" width="303" height="20"/>
260+
<rect key="frame" x="101.00000067379159" y="239.0000017943762" width="303" height="20"/>
261261
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES"/>
262262
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="How to use iReSign" id="QDO-Yr-Chc">
263-
<font key="font" size="14" name="LucidaGrande-Bold"/>
263+
<font key="font" metaFont="systemBold" size="14"/>
264264
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
265265
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
266266
</textFieldCell>
@@ -269,7 +269,7 @@
269269
<rect key="frame" x="101.00000067379159" y="49" width="303" height="182"/>
270270
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
271271
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="yH0-zO-1ov">
272-
<font key="font" size="11" name="LucidaGrande"/>
272+
<font key="font" metaFont="smallSystem"/>
273273
<string key="title">iReSign allows you to re-sign any unencrypted ipa-file with any certificate for which you hold the corresponding private key.
274274

275275
1. Drag your unsigned .ipa file to the top box, or use the browse button.
@@ -302,4 +302,4 @@ DQ
302302
<resources>
303303
<image name="Icon" width="128" height="128"/>
304304
</resources>
305-
</document>
305+
</document>

iReSign/iReSign/iReSignAppDelegate.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
NSTask *zipTask;
2626
NSString *sourcePath;
2727
NSString *appPath;
28+
NSString *frameworksDirPath;
29+
NSString *frameworkPath;
2830
NSString *workingPath;
2931
NSString *appName;
3032
NSString *fileName;
@@ -33,6 +35,9 @@
3335
NSString *codesigningResult;
3436
NSString *verificationResult;
3537

38+
NSMutableArray *frameworks;
39+
Boolean hasFrameworks;
40+
3641
IBOutlet IRTextFieldDrag *pathField;
3742
IBOutlet IRTextFieldDrag *provisioningPathField;
3843
IBOutlet IRTextFieldDrag *entitlementField;

iReSign/iReSign/iReSignAppDelegate.m

Lines changed: 86 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
static NSString *kKeyBundleIDPlistiTunesArtwork = @"softwareVersionBundleId";
1616
static NSString *kKeyInfoPlistApplicationProperties = @"ApplicationProperties";
1717
static NSString *kKeyInfoPlistApplicationPath = @"ApplicationPath";
18+
static NSString *kFrameworksDirName = @"Frameworks";
1819
static NSString *kPayloadDirName = @"Payload";
1920
static NSString *kProductsDirName = @"Products";
2021
static NSString *kInfoPlistFilename = @"Info.plist";
@@ -428,73 +429,101 @@ - (void)doEntitlementsEdit
428429

429430
- (void)doCodeSigning {
430431
appPath = nil;
432+
frameworksDirPath = nil;
433+
hasFrameworks = NO;
434+
frameworks = [[NSMutableArray alloc] init];
431435

432436
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[workingPath stringByAppendingPathComponent:kPayloadDirName] error:nil];
433437

434438
for (NSString *file in dirContents) {
435439
if ([[[file pathExtension] lowercaseString] isEqualToString:@"app"]) {
436440
appPath = [[workingPath stringByAppendingPathComponent:kPayloadDirName] stringByAppendingPathComponent:file];
441+
frameworksDirPath = [appPath stringByAppendingPathComponent:kFrameworksDirName];
437442
NSLog(@"Found %@",appPath);
438443
appName = file;
444+
if ([[NSFileManager defaultManager] fileExistsAtPath:frameworksDirPath]) {
445+
NSLog(@"Found %@",frameworksDirPath);
446+
hasFrameworks = YES;
447+
NSArray *frameworksContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:frameworksDirPath error:nil];
448+
for (NSString *frameworkFile in frameworksContents) {
449+
if ([[[frameworkFile pathExtension] lowercaseString] isEqualTo:@"framework"]) {
450+
frameworkPath = [frameworksDirPath stringByAppendingPathComponent:frameworkFile];
451+
NSLog(@"Found %@",frameworkPath);
452+
[frameworks addObject:frameworkPath];
453+
}
454+
}
455+
}
439456
[statusLabel setStringValue:[NSString stringWithFormat:@"Codesigning %@",file]];
440457
break;
441458
}
442459
}
443460

444461
if (appPath) {
445-
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", [certComboBox objectValue], nil];
446-
NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
447-
NSString * systemVersion = [systemVersionDictionary objectForKey:@"ProductVersion"];
448-
NSArray * version = [systemVersion componentsSeparatedByString:@"."];
449-
if ([version[0] intValue]<10 || ([version[0] intValue]==10 && ([version[1] intValue]<9 || ([version[1] intValue]==9 && [version[2] intValue]<5)))) {
450-
451-
/*
452-
Before OSX 10.9, code signing requires a version 1 signature.
453-
The resource envelope is necessary.
454-
To ensure it is added, append the resource flag to the arguments.
455-
*/
456-
457-
NSString *resourceRulesPath = [[NSBundle mainBundle] pathForResource:@"ResourceRules" ofType:@"plist"];
458-
NSString *resourceRulesArgument = [NSString stringWithFormat:@"--resource-rules=%@",resourceRulesPath];
459-
[arguments addObject:resourceRulesArgument];
462+
if (hasFrameworks) {
463+
[self signFile:[frameworks lastObject]];
464+
[frameworks removeLastObject];
460465
} else {
461-
462-
/*
463-
For OSX 10.9 and later, code signing requires a version 2 signature.
464-
The resource envelope is obsolete.
465-
To ensure it is ignored, remove the resource key from the Info.plist file.
466-
*/
467-
468-
NSString *infoPath = [NSString stringWithFormat:@"%@/Info.plist", appPath];
469-
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:infoPath];
470-
[infoDict removeObjectForKey:@"CFBundleResourceSpecification"];
471-
[infoDict writeToFile:infoPath atomically:YES];
472-
[arguments addObject:@"--no-strict"]; // http://stackoverflow.com/a/26204757
473-
}
474-
475-
if (![[entitlementField stringValue] isEqualToString:@""]) {
476-
[arguments addObject:[NSString stringWithFormat:@"--entitlements=%@", [entitlementField stringValue]]];
466+
[self signFile:appPath];
477467
}
468+
}
469+
}
470+
471+
- (void)signFile:(NSString*)filePath {
472+
NSLog(@"Codesigning %@", filePath);
473+
[statusLabel setStringValue:[NSString stringWithFormat:@"Codesigning %@",filePath]];
474+
475+
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", [certComboBox objectValue], nil];
476+
NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
477+
NSString * systemVersion = [systemVersionDictionary objectForKey:@"ProductVersion"];
478+
NSArray * version = [systemVersion componentsSeparatedByString:@"."];
479+
if ([version[0] intValue]<10 || ([version[0] intValue]==10 && ([version[1] intValue]<9 || ([version[1] intValue]==9 && [version[2] intValue]<5)))) {
478480

479-
[arguments addObjectsFromArray:[NSArray arrayWithObjects:appPath, nil]];
480-
481-
codesignTask = [[NSTask alloc] init];
482-
[codesignTask setLaunchPath:@"/usr/bin/codesign"];
483-
[codesignTask setArguments:arguments];
484-
485-
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkCodesigning:) userInfo:nil repeats:TRUE];
486-
481+
/*
482+
Before OSX 10.9, code signing requires a version 1 signature.
483+
The resource envelope is necessary.
484+
To ensure it is added, append the resource flag to the arguments.
485+
*/
487486

488-
NSPipe *pipe=[NSPipe pipe];
489-
[codesignTask setStandardOutput:pipe];
490-
[codesignTask setStandardError:pipe];
491-
NSFileHandle *handle=[pipe fileHandleForReading];
487+
NSString *resourceRulesPath = [[NSBundle mainBundle] pathForResource:@"ResourceRules" ofType:@"plist"];
488+
NSString *resourceRulesArgument = [NSString stringWithFormat:@"--resource-rules=%@",resourceRulesPath];
489+
[arguments addObject:resourceRulesArgument];
490+
} else {
492491

493-
[codesignTask launch];
492+
/*
493+
For OSX 10.9 and later, code signing requires a version 2 signature.
494+
The resource envelope is obsolete.
495+
To ensure it is ignored, remove the resource key from the Info.plist file.
496+
*/
494497

495-
[NSThread detachNewThreadSelector:@selector(watchCodesigning:)
496-
toTarget:self withObject:handle];
498+
NSString *infoPath = [NSString stringWithFormat:@"%@/Info.plist", filePath];
499+
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:infoPath];
500+
[infoDict removeObjectForKey:@"CFBundleResourceSpecification"];
501+
[infoDict writeToFile:infoPath atomically:YES];
502+
[arguments addObject:@"--no-strict"]; // http://stackoverflow.com/a/26204757
503+
}
504+
505+
if (![[entitlementField stringValue] isEqualToString:@""]) {
506+
[arguments addObject:[NSString stringWithFormat:@"--entitlements=%@", [entitlementField stringValue]]];
497507
}
508+
509+
[arguments addObjectsFromArray:[NSArray arrayWithObjects:filePath, nil]];
510+
511+
codesignTask = [[NSTask alloc] init];
512+
[codesignTask setLaunchPath:@"/usr/bin/codesign"];
513+
[codesignTask setArguments:arguments];
514+
515+
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkCodesigning:) userInfo:nil repeats:TRUE];
516+
517+
518+
NSPipe *pipe=[NSPipe pipe];
519+
[codesignTask setStandardOutput:pipe];
520+
[codesignTask setStandardError:pipe];
521+
NSFileHandle *handle=[pipe fileHandleForReading];
522+
523+
[codesignTask launch];
524+
525+
[NSThread detachNewThreadSelector:@selector(watchCodesigning:)
526+
toTarget:self withObject:handle];
498527
}
499528

500529
- (void)watchCodesigning:(NSFileHandle*)streamHandle {
@@ -509,9 +538,17 @@ - (void)checkCodesigning:(NSTimer *)timer {
509538
if ([codesignTask isRunning] == 0) {
510539
[timer invalidate];
511540
codesignTask = nil;
512-
NSLog(@"Codesigning done");
513-
[statusLabel setStringValue:@"Codesigning completed"];
514-
[self doVerifySignature];
541+
if (frameworks.count > 0) {
542+
[self signFile:[frameworks lastObject]];
543+
[frameworks removeLastObject];
544+
} else if (hasFrameworks) {
545+
hasFrameworks = NO;
546+
[self signFile:appPath];
547+
} else {
548+
NSLog(@"Codesigning done");
549+
[statusLabel setStringValue:@"Codesigning completed"];
550+
[self doVerifySignature];
551+
}
515552
}
516553
}
517554

0 commit comments

Comments
 (0)