def main(): parser = argparse.ArgumentParser(description='Sign a B2G app manifest.') parser.add_argument('-d', action='store', required=True, help='NSS database directory') parser.add_argument('-f', action='store', type=argparse.FileType('rb'), required=True, help='password file') parser.add_argument('-k', action='store', required=True, help="nickname of signing cert.") parser.add_argument('-i', action='store', type=argparse.FileType('rb'), required=True, help="input manifest file (unsigned)") parser.add_argument('-o', action='store', type=argparse.FileType('wb'), required=True, help="output manifest file (signed)") args = parser.parse_args() db_dir = args.d password = args.f.readline().strip() cert_nickname = args.k cert = None try: nss_ctypes.NSS_Init(db_dir) wincx = nss_ctypes.SetPasswordContext(password) cert = nss_ctypes.PK11_FindCertFromNickname(cert_nickname, wincx) sign_file(args.i, args.o, cert, wincx) return 0 finally: nss_ctypes.CERT_DestroyCertificate(cert) nss_ctypes.NSS_Shutdown()
def main(): parser = argparse.ArgumentParser(description='Sign a B2G app.') parser.add_argument('-d', action='store', required=True, help='NSS database directory') parser.add_argument('-f', action='store', type=argparse.FileType('rb'), required=True, help='password file') parser.add_argument('-k', action='store', required=True, help="nickname of signing cert.") parser.add_argument('-i', action='store', type=argparse.FileType('rb'), required=True, help="input JAR file (unsigned)") parser.add_argument('-o', action='store', type=argparse.FileType('wb'), required=True, help="output JAR file (signed)") parser.add_argument('-I', '--ids-file', action='store', type=argparse.FileType('rb'), help="Path to the ids.json file", dest='I') parser.add_argument('-S', '--storeId', action='store', help="Store Id for the package", dest='S') parser.add_argument('-V', '--storeVersion', action='store', type=int, help="Package Version", dest='V') args = parser.parse_args() # Sadly nested groups and neccesarily inclusive groups (http://bugs.python.org/issue11588) # are not implemented. Note that this means the automatic help is slighty incorrect if not((not args.I and args.V and args.S) or (args.I and not args.V and not args.S)): raise ValueError("Either -I or -S and -V must be specified") if (args.I): ids_contents = args.I.read(max_entry_uncompressed_len+1) else: ids_contents = '''{ "id": "%(id)s", "version": %(version)d } ''' % {"id": args.S, "version": args.V} if len(ids_contents) > max_entry_uncompressed_len: raise ValueError("Entry is too large: %s" % (name)) db_dir = args.d password = args.f.readline().strip() cert_nickname = args.k (wincx, cert) = nss_load_cert(db_dir, password, cert_nickname) try: sign_zip(args.i, args.o, cert, wincx, ids_contents) return 0 finally: nss_ctypes.CERT_DestroyCertificate(cert) nss_ctypes.NSS_Shutdown()
def main(): parser = argparse.ArgumentParser(description='Sign a B2G app.') parser.add_argument('-d', action='store', required=True, help='NSS database directory') parser.add_argument('-f', action='store', type=argparse.FileType('rb'), required=True, help='password file') parser.add_argument('-k', action='store', required=True, help="nickname of signing cert.") parser.add_argument('-i', action='store', type=argparse.FileType('rb'), required=True, help="input JAR file (unsigned)") parser.add_argument('-o', action='store', type=argparse.FileType('wb'), required=True, help="output JAR file (signed)") args = parser.parse_args() db_dir = args.d password = args.f.readline().strip() cert_nickname = args.k (wincx, cert) = nss_load_cert(db_dir, password, cert_nickname) try: sign_zip(args.i, args.o, cert, wincx) return 0 finally: nss_ctypes.CERT_DestroyCertificate(cert) nss_ctypes.NSS_Shutdown()