def extract_entitlements(self, provision_path): cmd = [ "smime", "-inform", "der", "-verify", "-in", provision_path ] profile_text = signer.openssl_command(cmd, None) plist_dict = biplist.readPlistFromString(profile_text) if "Entitlements" in plist_dict: biplist.writePlist(plist_dict["Entitlements"], self.entitlements_path, binary=False) log.debug("wrote Entitlements to {0}".format(self.entitlements_path)) else: log.debug("failed to write entitlements")
def extract_entitlements(provision_path): """ Given a path to a provisioning profile, return the entitlements encoded therein """ cmd = [ 'smime', '-inform', 'der', '-verify', # verifies content, prints verification status to STDERR, # outputs content to STDOUT. In our case, will be an XML plist '-noverify', # accept self-signed certs. Not the opposite of -verify! '-in', provision_path ] # this command always prints 'Verification successful' to stderr. (profile_text, err) = openssl_command(cmd, data=None, expect_err=True) if err and err.strip() != 'Verification successful': log.error('Received unexpected error from openssl: {}'.format(err)) plist_dict = biplist.readPlistFromString(profile_text) if 'Entitlements' not in plist_dict: log.debug('failed to get entitlements in provisioning profile') raise Exception('could not find Entitlements in {}'.format(provision_path)) return plist_dict['Entitlements']