Skip to content

Commit

Permalink
- Added an option to manually update the WWDR certificate to the help…
Browse files Browse the repository at this point in the history
… menu

- Fixed a bug where the main executable of an IPA sometimes didn't have the executable attribute set
  • Loading branch information
DanTheMan827 committed May 7, 2016
1 parent bd14595 commit 9be5798
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 37 deletions.
8 changes: 8 additions & 0 deletions AppSigner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var mainView: MainView!
let fileManager = NSFileManager.defaultManager()


Expand All @@ -26,6 +27,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
return true
}
@IBAction func fixSigning(sender: NSMenuItem) {
if let tempFolder = mainView.makeTempFolder() {
iASShared.fixSigning(tempFolder)
try? fileManager.removeItemAtPath(tempFolder)
mainView.populateCodesigningCerts()
}
}

@IBAction func nsMenuLinkClick(sender: NSMenuLink) {
NSWorkspace.sharedWorkspace().openURL(NSURL(string: sender.url!)!)
Expand Down
18 changes: 14 additions & 4 deletions AppSigner/Application.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -11,7 +11,11 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="aMe-uV-AHx" customClass="AppDelegate" customModule="iOS_App_Signer" customModuleProvider="target"/>
<customObject id="aMe-uV-AHx" customClass="AppDelegate" customModule="iOS_App_Signer" customModuleProvider="target">
<connections>
<outlet property="mainView" destination="se5-gp-TjO" id="Mal-fb-Nqp"/>
</connections>
</customObject>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
Expand Down Expand Up @@ -94,6 +98,12 @@
<action selector="nsMenuLinkClick:" target="aMe-uV-AHx" id="kuT-Sl-Lfb"/>
</connections>
</menuItem>
<menuItem title="Update Apple WWDR Certificate" id="yW3-3F-UGM">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="fixSigning:" target="aMe-uV-AHx" id="11N-yH-9Q4"/>
</connections>
</menuItem>
<menuItem title="Check for Updates" id="z6H-Tg-1uh">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand All @@ -109,7 +119,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" unifiedTitleAndToolbar="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="550" height="181"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1080"/>
<value key="minSize" type="size" width="550" height="181"/>
<value key="maxSize" type="size" width="9999" height="181"/>
<view key="contentView" id="se5-gp-TjO" customClass="MainView" customModule="iOS_App_Signer" customModuleProvider="target">
Expand Down
17 changes: 17 additions & 0 deletions AppSigner/Classes/iASShared.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// iASShared.swift
// iOS App Signer
//
// Created by Daniel Radtke on 5/7/16.
// Copyright © 2016 Daniel Radtke. All rights reserved.
//

import Foundation
class iASShared {
static func fixSigning(tempFolder: String){
let script = "do shell script \"/bin/bash \\\"\(NSBundle.mainBundle().pathForResource("fix-wwdr", ofType: "sh")!)\\\"\" with administrator privileges"
NSAppleScript(source: script)?.executeAndReturnError(nil)
//https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
return
}
}
4 changes: 2 additions & 2 deletions AppSigner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.8</string>
<string>1.8.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>1.8.1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSMinimumSystemVersion</key>
Expand Down
29 changes: 15 additions & 14 deletions AppSigner/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
let defaultsPath = "/usr/bin/defaults"
let codesignPath = "/usr/bin/codesign"
let securityPath = "/usr/bin/security"
let chmodPath = "/bin/chmod"

//MARK: Drag / Drop
var fileTypes: [String] = ["ipa","deb","app","xcarchive","mobileprovision"]
Expand Down Expand Up @@ -216,7 +217,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes

var index: Int

for index = 0; index <= rawResult.count - 2; index+=2 {
for index in 0.stride(through: rawResult.count - 2, by: 2) {
if !(rawResult.count - 1 < index + 1) {
output.append(rawResult[index+1])
}
Expand All @@ -232,7 +233,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
alert.addButtonWithTitle("No")
if alert.runModal() == NSAlertFirstButtonReturn {
if let tempFolder = makeTempFolder() {
fixSigning(tempFolder)
iASShared.fixSigning(tempFolder)
try? fileManager.removeItemAtPath(tempFolder)
populateCodesigningCerts()
}
Expand Down Expand Up @@ -444,12 +445,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
return nil
}
func fixSigning(tempFolder: String){
let script = "do shell script \"/bin/bash \\\"\(NSBundle.mainBundle().pathForResource("fix-wwdr", ofType: "sh")!)\\\"\" with administrator privileges"
NSAppleScript(source: script)?.executeAndReturnError(nil)
//https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
return
}

func startSigning() {
controlsEnabled(false)

Expand All @@ -459,7 +455,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
saveDialog.nameFieldStringValue = InputFileText.stringValue.lastPathComponent.stringByDeletingPathExtension
if saveDialog.runModal() == NSFileHandlingPanelOKButton {
outputFile = saveDialog.URL!.path
NSThread.detachNewThreadSelector(Selector("signingThread"), toTarget: self, withObject: nil)
NSThread.detachNewThreadSelector(#selector(self.signingThread), toTarget: self, withObject: nil)
} else {
outputFile = nil
controlsEnabled(true)
Expand Down Expand Up @@ -529,7 +525,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
alert.informativeText = "You appear to have a error with your codesigning certificate, do you want me to try and fix the problem?"
let response = alert.runModal()
if response == NSAlertFirstButtonReturn {
self.fixSigning(tempFolder)
iASShared.fixSigning(tempFolder)
if self.testSigning(signingCertificate!, tempFolder: tempFolder) == false {
let errorAlert = NSAlert()
errorAlert.messageText = "Unable to Fix"
Expand Down Expand Up @@ -757,19 +753,24 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
} else {
setStatus("Unable to read entitlements from provisioning profile")
warnings++
warnings += 1
}
if profile.appID != "*" && (newApplicationID != "" && newApplicationID != profile.appID) {
setStatus("Unable to change App ID to \(newApplicationID), provisioning profile won't allow it")
cleanup(tempFolder); return
}
} else {
setStatus("Unable to parse provisioning profile, it may be corrupt")
warnings++
warnings += 1
}

}

//MARK: Make sure that the executable is well... executable.
if let bundleExecutable = getPlistKey(appBundleInfoPlist, keyName: "CFBundleExecutable"){
NSTask().execute(chmodPath, workingDirectory: nil, arguments: ["755", appBundlePath.stringByAppendingPathComponent(bundleExecutable)])
}

//MARK: Change Application ID
if newApplicationID != "" {

Expand Down Expand Up @@ -834,7 +835,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
if codesignOutput.status != 0 {
setStatus("Error codesigning \(shortName(file, payloadDirectory: payloadDirectory))")
Log.write(codesignOutput.output)
warnings++
warnings += 1
}
}

Expand All @@ -850,7 +851,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
//MARK: Codesigning - Eggs
let eggSigningFunction = generateFileSignFunc(eggDirectory, entitlementsPath: entitlementsPlist, signingCertificate: signingCertificate!)
func signEgg(eggFile: String){
eggCount++
eggCount += 1

let currentEggPath = eggDirectory.stringByAppendingPathComponent("egg\(eggCount)")
let shortName = eggFile.substringFromIndex(payloadDirectory.endIndex)
Expand Down
20 changes: 10 additions & 10 deletions AppSigner/Updates.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="UpdatesController" customModule="iOS_App_Signer" customModuleProvider="target">
Expand All @@ -20,7 +20,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="615" height="344"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<value key="minSize" type="size" width="615" height="230"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="615" height="344"/>
Expand Down Expand Up @@ -61,18 +61,18 @@
<scrollView misplaced="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uB7-Qr-xtC">
<rect key="frame" x="92" y="49" width="503" height="200"/>
<clipView key="contentView" copiesOnScroll="NO" id="xQc-hh-esc">
<rect key="frame" x="1" y="1" width="501" height="198"/>
<rect key="frame" x="1" y="1" width="486" height="198"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" verticallyResizable="YES" allowsNonContiguousLayout="YES" id="9oR-gz-UUY">
<rect key="frame" x="0.0" y="0.0" width="501" height="198"/>
<rect key="frame" x="0.0" y="0.0" width="486" height="198"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="501" height="198"/>
<size key="maxSize" width="501" height="10000000"/>
<size key="minSize" width="486" height="198"/>
<size key="maxSize" width="503" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="501" height="198"/>
<size key="maxSize" width="501" height="10000000"/>
<size key="minSize" width="486" height="198"/>
<size key="maxSize" width="503" height="10000000"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -82,7 +82,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Yeh-63-iCe">
<rect key="frame" x="486" y="1" width="16" height="198"/>
<rect key="frame" x="487" y="1" width="15" height="198"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down
16 changes: 9 additions & 7 deletions AppSigner/UpdatesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,26 @@ class UpdatesController: NSWindowController {
super.showWindow(sender)
appIcon.image = NSWorkspace.sharedWorkspace().iconForFile(NSBundle.mainBundle().bundlePath)
var releaseOutput: [String] = []
if let releases = sender![1] as? [[String: AnyObject]],
currentVersion = sender![0] as? String {
for release in releases {
if let name = release["name"] as? String,
body = release["body"] as? String {
if let senderArray = sender as? [AnyObject] {
if let releases = senderArray[1] as? [[String: AnyObject]],
currentVersion = senderArray[0] as? String {
for release in releases {
if let name = release["name"] as? String,
body = release["body"] as? String {
if latestVersion == nil {
latestVersion = name
}
if currentVersion == name {
break
}
releaseOutput.append("**Version \(name)**\n\(body)")
}
}
versionLabel.stringValue = "Version \(latestVersion!) is now available, you have \(currentVersion)."
}
versionLabel.stringValue = "Version \(latestVersion!) is now available, you have \(currentVersion)."
setChangelog(releaseOutput.joinWithSeparator("\n\n"))
}

setChangelog(releaseOutput.joinWithSeparator("\n\n"))
}
func setChangelog(text: String){
changelogText.editable = true
Expand Down
4 changes: 4 additions & 0 deletions iOS App Signer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
659734A11C65B5F600383D2D /* MarkdownTokens.m in Sources */ = {isa = PBXBuildFile; fileRef = 6597349C1C65B5F600383D2D /* MarkdownTokens.m */; };
659734A21C65B5F600383D2D /* NSAttributedStringMarkdownParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 6597349F1C65B5F600383D2D /* NSAttributedStringMarkdownParser.m */; };
659734A71C65B94F00383D2D /* fmemopen.c in Sources */ = {isa = PBXBuildFile; fileRef = 659734A41C65B94F00383D2D /* fmemopen.c */; };
65B2EAA21CDE981500D02053 /* iASShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B2EAA11CDE981500D02053 /* iASShared.swift */; };
65CED3A32D8B6F3E00E9185B /* fix-wwdr.sh in Resources */ = {isa = PBXBuildFile; fileRef = 65CED3A22D8B6F3E00E9185B /* fix-wwdr.sh */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -50,6 +51,7 @@
659734A51C65B94F00383D2D /* fmemopen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fmemopen.h; path = NimbusKit/memorymapping/fmemopen.h; sourceTree = "<group>"; };
659734A61C65B94F00383D2D /* NimbusMemoryMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NimbusMemoryMapping.h; path = NimbusKit/memorymapping/NimbusMemoryMapping.h; sourceTree = "<group>"; };
65B24E0D1BECB30D005D2068 /* AppSigner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = AppSigner.entitlements; sourceTree = "<group>"; };
65B2EAA11CDE981500D02053 /* iASShared.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iASShared.swift; path = AppSigner/Classes/iASShared.swift; sourceTree = "<group>"; };
65CED3A22D8B6F3E00E9185B /* fix-wwdr.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "fix-wwdr.sh"; path = "Resources/fix-wwdr.sh"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -105,6 +107,7 @@
655FFFA11BEAD93600D43AD8 /* ProvisioningProfile.swift */,
65311EAF1BF835F100516EFD /* Log.swift */,
65311EAD1BF8259000516EFD /* NSMenuLink.swift */,
65B2EAA11CDE981500D02053 /* iASShared.swift */,
);
name = Classes;
path = ..;
Expand Down Expand Up @@ -251,6 +254,7 @@
655FFF9D1BE9B3E300D43AD8 /* NSTask-execute.swift in Sources */,
659734A21C65B5F600383D2D /* NSAttributedStringMarkdownParser.m in Sources */,
655FFFA21BEAD93600D43AD8 /* ProvisioningProfile.swift in Sources */,
65B2EAA21CDE981500D02053 /* iASShared.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 9be5798

Please sign in to comment.