Skip to content

Instantly share code, notes, and snippets.

@koenbok
Created May 14, 2014 13:26
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save koenbok/f044ac3ea8a3ec756a2c to your computer and use it in GitHub Desktop.
Save koenbok/f044ac3ea8a3ec756a2c to your computer and use it in GitHub Desktop.
Mac Desktop Code Sign Script
#!/usr/bin/env python
import os
import sys
import shutil
import subprocess
if len(sys.argv) < 3:
sys.exit("Usage: python sign.py <identity> <myApp.app>")
SCRIPT, IDENTITY, APP_PATH = sys.argv
def run(command):
return subprocess.check_output(command, shell=True)
def listIdentities():
run("certtool y | grep Developer\ ID")
run("security find-identity")
def sign(path):
run("codesign --verbose --force --sign '%s' '%s'" % (IDENTITY, path))
def signDir(path):
if not os.path.exists(path):
return
for name in os.listdir(path):
sign(os.path.join(path, name))
def signCheck(path):
run("codesign --verify --verbose=100 '%s'" % (path))
run("spctl -vvvvvv --assess --type execute '%s'" % (path))
applicationPath = os.path.abspath(APP_PATH)
signedApplicationPath = applicationPath
# Extract specific paths from the application
signedApplicationFrameworksPath = os.path.join(signedApplicationPath, "Contents", "Frameworks")
signedApplicationLibrariesPath = os.path.join(signedApplicationPath, "Contents", "Libraries")
# Sign all the frameworks
signDir(signedApplicationFrameworksPath)
# Sign all the libraries
signDir(signedApplicationLibrariesPath)
# Sign the application bundle
sign(signedApplicationPath)
signCheck(signedApplicationPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment