can i ask for update on this matter? is it progressing (migration)? are you expecting some more breaking changes?
also i have 'extended' sign.py file that i would like to push upstream - of course if you agree.
however i never commited anything to google codebase and i dont want to complete every steps that is needed to do so.
would you be able to upstream it for me? ive added ability to sign files using pfx cert file.
it is python 3.4 - not sure if you need it lower - i can make it python 2 compatible if needed - give me a msg
the license is anything you want it to be - bsd, public domain or anything that you need to make it upstream.
diff --git a/chrome/updater/win/signing/sign.py b/chrome/updater/win/signing/sign.py
index bb3a7285de..cfabf96bb3 100755
--- a/chrome/updater/win/signing/sign.py
+++ b/chrome/updater/win/signing/sign.py
@@ -20,10 +20,17 @@ import os.path
import shutil
import subprocess
import tempfile
+from enum import IntEnum
+import sys
import resedit
+class MethodType(IntEnum):
+ Identity = 0
+ CertFile = 1
+
+
class SigningError(Exception):
"""Module exception class."""
@@ -31,13 +38,17 @@ class SigningError(Exception):
class Signer:
"""A container for a signing operation."""
- def __init__(self, tmpdir, lzma_exe, signtool_exe, tagging_exe, identity):
+ def __init__(self, tmpdir, lzma_exe, signtool_exe, tagging_exe, method,
+ identity, cert_file, cert_file_pwd):
"""Inits a signer with the necessary tools."""
self._tmpdir = tmpdir
self._lzma_exe = lzma_exe
self._signtool_exe = signtool_exe
self._tagging_exe = tagging_exe
+ self._method = method
self._identity = identity
+ self._cert_file = cert_file
+ self._cert_file_pwd = cert_file_pwd
def _add_tagging_cert(self, in_file):
"""Adds the tagging cert. Returns the path to the tagged file."""
@@ -56,9 +67,17 @@ class Signer:
# Retries may be required: lore states the timestamp server is flaky.
command = [
self._signtool_exe, 'sign', '/v', '/tr',
- '
http://timestamp.digicert.com', '/td', 'SHA256', '/fd', 'SHA256',
- '/s', 'my', '/n', self._identity, in_file
+ '
http://timestamp.digicert.com', '/td', 'SHA256'
]
+ if self._method == MethodType.CertFile:
+ command.extend([
+ '/fd', 'certHash', '/f', self._cert_file,
+ '/p', self._cert_file_pwd, in_file
+ ])
+ else: # self._method == MethodType.Identity
+ command.extend([
+ '/fd', 'SHA256', '/s', 'my', '/n', self._identity, in_file
+ ])
subprocess.run(command, check=True)
def _sign_7z(self, in_file):
@@ -116,14 +135,33 @@ def main():
parser.add_argument('--certificate_tag',
default='.\certificate_tag.exe',
help='The path to the certificate_tag executable.')
+ parser.add_argument(
+ '--method',
+ default='identity',
+ help='It can be either system added cert "identity" or "cert_file".')
parser.add_argument('--identity',
default='Google',
help='The signing identity to use.')
+ parser.add_argument('--cert_file',
+ default='',
+ help='The path to the certificate file(.pfx).')
+ parser.add_argument('--cert_file_password',
+ default='',
+ help='The password to the certificate file.')
args = parser.parse_args()
+ method = MethodType.Identity
+ if args.method == 'identity':
+ method = MethodType.Identity
+ elif args.method == 'cert_file':
+ method = MethodType.CertFile
+ else:
+ sys.exit('invalid method param - check help')
+
with tempfile.TemporaryDirectory() as tmpdir:
shutil.move(
Signer(tmpdir, args.lzma_7z, args.signtool, args.certificate_tag,
- args.identity).sign_metainstaller(args.in_file),
+ method, args.identity, args.cert_file,
+ args.cert_file_password).sign_metainstaller(args.in_file),
args.out_file)