Пример #1
0
 def __init__(self, path):
     self.path = path
     if not self.is_helpers_present():
         raise NotSignable("helpers not present")
     relative_app_dir, is_native = self.precheck()
     self.relative_app_dir = relative_app_dir
     if relative_app_dir is None:
         raise NotMatched("no app directory found")
     if not is_native:
         raise NotMatched("not a native iOS app")
Пример #2
0
def process_watchkit(root_bundle_path, should_remove=False):
    """ Unfortunately, we currently can't sign WatchKit. If you don't
        care about watchkit functionality, it is
        generally harmless to remove it, so that's the default.
        Remove when https://github.com/saucelabs/isign/issues/20 is fixed """
    watchkit_paths = get_watchkit_paths(root_bundle_path)
    if len(watchkit_paths) > 0:
        if should_remove:
            for path in watchkit_paths:
                log.warning("Removing WatchKit bundle {}".format(path))
                shutil.rmtree(path)
        else:
            raise NotSignable("Cannot yet sign WatchKit bundles")
Пример #3
0
def archive_factory(path):
    """ Guess what kind of archive we are dealing with, return an
        archive object. """
    if isdir(path):
        try:
            return AppArchive(path)
        except NotSignable as e:
            log.error("Error initializing app dir: %s", e)
            raise NotSignable(e)
    else:
        obj = None
        for cls in [AppZip, Ipa]:
            try:
                obj = cls(path)
                log.debug("File %s matched as %s", path, cls.__name__)
                break
            except NotMatched as e:
                log.debug("File %s not matched as %s: %s", path, cls, e)
        if obj is not None:
            return obj

    raise NotSignable("No matching app format found for %s" % path)
Пример #4
0
def resign(input_path,
           deep,
           certificate,
           key,
           apple_cert,
           provisioning_profile,
           output_path,
           info_props=None,
           alternate_entitlements_path=None):
    """ Unified interface to extract any kind of archive from
        a temporary file, resign it with these credentials,
        and create a similar archive for that resigned app """

    if not exists(input_path):
        raise IOError("{0} not found".format(input_path))


    if key == None:
        log.debug('Signing ad-hoc')
        signer = AdhocSigner()
    else:
        log.debug('Signing with apple_cert: {}'.format(apple_cert))
        log.debug('Signing with key: {}'.format(key))
        log.debug('Signing with certificate: {}'.format(certificate))
        log.debug('Signing with provisioning_profile: {}'.format(provisioning_profile))
        signer = Signer(signer_cert_file=certificate,
                        signer_key_file=key,
                        apple_cert_file=apple_cert)
    ua = None
    bundle_info = None
    try:
        archive = archive_factory(input_path)
        if archive is None:
            raise NotSignable('No matching archive type found')
        ua = archive.unarchive_to_temp()
        if info_props:
            # Override info.plist props of the parent bundle
            ua.bundle.update_info_props(info_props)
        ua.bundle.resign(deep, signer, provisioning_profile, alternate_entitlements_path)
        bundle_info = ua.bundle.info
        ua.archive(output_path)
    except NotSignable as e:
        msg = "Not signable: <{0}>: {1}\n".format(input_path, e)
        log.info(msg)
        raise
    finally:
        if ua is not None:
            ua.remove()
    return bundle_info