Created
July 11, 2015 06:44
-
-
Save Seasons7/205a9ab5f6e578580a28 to your computer and use it in GitHub Desktop.
Keychain codesign information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commands | |
import re | |
def get_codesign_entries_from_keychain(): | |
cm = 'security find-identity -v -p codesigning' | |
result = commands.getoutput(cm) | |
entries = [] | |
if result: | |
items = result.split('\n') | |
for item in items: | |
m = re.search('([0-9A-Z]{40,})\s+\"(.+)\(([0-9A-Z]{10,})\)\"', item) | |
if m: | |
teamID = str(m.group(3)) | |
certificate = str(m.group(2)) | |
entry = (teamID, certificate + "(" + teamID + ")") | |
# (teamID, certificate) | |
entries.append(entry) | |
return entries | |
def select_codesign_entry(): | |
entries = get_codesign_entries_from_keychain() | |
if entries: | |
number = 1 | |
for teamID, cert in entries: | |
print(str(number) + " : " + cert) | |
number += 1 | |
while True: | |
print('Select number(' + str(number) + ' = Exit) >>') | |
value = input() | |
if 0 < value and value < number: | |
value -= 1 | |
return entries[value] | |
if value == number: | |
break | |
if __name__ == '__main__': | |
ret = select_codesign_entry() | |
print(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment