def GetSigner(context): if args.subparser_name in ["repack", "buildandrepack"]: if args.platform == "windows": print "Enter passphrase for code signing cert:" passwd = getpass.getpass() cert = config_lib.CONFIG.Get("ClientBuilder.windows_signing_cert", context=context) key = config_lib.CONFIG.Get("ClientBuilder.windows_signing_key", context=context) app_name = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_application_name", context=context) return signing.WindowsCodeSigner(cert, key, passwd, app_name) elif args.platform == "linux" and args.package_format == "rpm": pub_keyfile = config_lib.CONFIG.Get( "ClientBuilder.rpm_signing_key_public_keyfile", context=context) gpg_name = config_lib.CONFIG.Get("ClientBuilder.rpm_gpg_name", context=context) print "Enter passphrase for code signing key %s:" % (gpg_name) passwd = getpass.getpass() return signing.RPMCodeSigner(passwd, pub_keyfile, gpg_name) else: parser.error( "Signing only supported on windows and linux rpms for " "repack, buildandrepack")
def GetSigner(self, context): if "Target:Windows" not in context and "Target:LinuxRpm" not in context: raise RuntimeError( "Signing only supported on windows and linux rpms. Neither target in" " context: %s" % context) passwd = self.GetSigningPassword() if "Target:Windows" in context: cert = config_lib.CONFIG.Get("ClientBuilder.windows_signing_cert", context=context) key = config_lib.CONFIG.Get("ClientBuilder.windows_signing_key", context=context) app_name = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_application_name", context=context) return signing.WindowsCodeSigner(cert, key, passwd, app_name) elif "Target:LinuxRpm" in context: pub_keyfile = config_lib.CONFIG.Get( "ClientBuilder.rpm_signing_key_public_keyfile", context=context) gpg_name = config_lib.CONFIG.Get("ClientBuilder.rpm_gpg_name", context=context) return signing.RPMCodeSigner(passwd, pub_keyfile, gpg_name)
def GetSigner(context): if args.platform == "windows" and args.subparser_name in ["deploy", "repack", "buildanddeploy"]: passwd = getpass.getpass() cert = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_cert", context=context) key = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_key", context=context) app_name = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_application_name", context=context) return signing.WindowsCodeSigner(cert, key, passwd, app_name) else: parser.error("Signing only supported on windows for deploy, repack," " buildanddeploy")
def _SignWindowsComponent(component, output_filename): print "Enter passphrase for code signing cert:" passwd = getpass.getpass() cert = config_lib.CONFIG.Get("ClientBuilder.windows_signing_cert") key = config_lib.CONFIG.Get("ClientBuilder.windows_signing_key") app_name = config_lib.CONFIG.Get( "ClientBuilder.windows_signing_application_name") signer = signing.WindowsCodeSigner(cert, key, passwd, app_name) with utils.TempDirectory() as temp_dir: zip_file = zipfile.ZipFile(StringIO.StringIO(component.raw_data)) zip_file.extractall(temp_dir) new_data = StringIO.StringIO() new_zipfile = zipfile.ZipFile(new_data, mode="w", compression=zipfile.ZIP_DEFLATED) for root, _, files in os.walk(temp_dir): for basename in files: basename = basename.lstrip("\\/") filename = os.path.join(root, basename) # The relative filename to the root of the zip file. relative_filename = filename[len(temp_dir):].lstrip("/") extension = os.path.splitext(filename)[1].lower() if extension in [".sys", ".exe", ".dll", ".pyd"]: out_filename = filename + ".signed" signer.SignFile(filename, out_filename=out_filename) new_zipfile.write(out_filename, arcname=relative_filename) else: new_zipfile.write(filename, arcname=relative_filename) # Flush the Zip file. new_zipfile.close() component.raw_data = new_data.getvalue() with open(output_filename, "wb") as out_fd: out_fd.write(component.SerializeToString())
def setUp(self): super(WindowsCodeSignerTest, self).setUp() self.winsign = signing.WindowsCodeSigner("", "", "", "")