find osslsigncode path

This commit is contained in:
olszomal 2022-07-22 14:10:22 +02:00 committed by Michał Trojnara
parent 26b7d5f617
commit 28c68aeebf

View File

@ -13,7 +13,6 @@ RESULT_PATH = os.getcwd()
FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/") FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/")
CERTS_PATH = os.path.join(RESULT_PATH, "./Testing/certs/") CERTS_PATH = os.path.join(RESULT_PATH, "./Testing/certs/")
CONF_PATH = os.path.join(RESULT_PATH, "./Testing/conf/") CONF_PATH = os.path.join(RESULT_PATH, "./Testing/conf/")
DEFAULT_PATH = os.path.join(RESULT_PATH, "./osslsigncode")
DEFAULT_IN = os.path.join(FILES_PATH, "./unsigned.exe") DEFAULT_IN = os.path.join(FILES_PATH, "./unsigned.exe")
DEFAULT_OUT = os.path.join(FILES_PATH, "./ts.exe") DEFAULT_OUT = os.path.join(FILES_PATH, "./ts.exe")
DEFAULT_CERT = os.path.join(CERTS_PATH, "./cert.pem") DEFAULT_CERT = os.path.join(CERTS_PATH, "./cert.pem")
@ -23,6 +22,13 @@ OPENSSL_CONF = os.path.join(CONF_PATH, "./openssl_tsa.cnf")
REQUEST = os.path.join(FILES_PATH, "./jreq.tsq") REQUEST = os.path.join(FILES_PATH, "./jreq.tsq")
RESPONS = os.path.join(FILES_PATH, "./jresp.tsr") RESPONS = os.path.join(FILES_PATH, "./jresp.tsr")
if os.path.exists(os.path.join(RESULT_PATH, "./Release/")):
OSSLSIGNCODE_FILE = os.path.join(RESULT_PATH, "./Release/osslsigncode")
elif os.path.exists(os.path.join(RESULT_PATH, "./Debug/")):
OSSLSIGNCODE_FILE = os.path.join(RESULT_PATH, "./Debug/osslsigncode")
else:
OSSLSIGNCODE_FILE = os.path.join(RESULT_PATH, "./osslsigncode")
DEFAULT_OPENSSL = ["openssl", "ts", DEFAULT_OPENSSL = ["openssl", "ts",
"-reply", "-config", OPENSSL_CONF, "-reply", "-config", OPENSSL_CONF,
"-passin", "pass:passme", "-passin", "pass:passme",
@ -111,7 +117,7 @@ def parse_args() -> str:
help="additional certificates" help="additional certificates"
) )
args = parser.parse_args() args = parser.parse_args()
program = [DEFAULT_PATH, "sign", "-in", args.input, "-out", args.output, program = [OSSLSIGNCODE_FILE, "sign", "-in", args.input, "-out", args.output,
"-certs", args.certs, "-key", args.key, "-certs", args.certs, "-key", args.key,
"-addUnauthenticatedBlob", "-add-msi-dse", "-comm", "-ph", "-jp", "low", "-addUnauthenticatedBlob", "-add-msi-dse", "-comm", "-ph", "-jp", "low",
"-h", "sha384", "-st", "1556668800", "-i", "https://www.osslsigncode.com/", "-h", "sha384", "-st", "1556668800", "-i", "https://www.osslsigncode.com/",
@ -130,8 +136,12 @@ def main() -> None:
osslsigncode.check_returncode() osslsigncode.check_returncode()
except subprocess.CalledProcessError as err: except subprocess.CalledProcessError as err:
ret = err.returncode ret = err.returncode
except OSError as err:
print(f"OSError: {err}")
ret = err.errno
except Exception as err: # pylint: disable=broad-except except Exception as err: # pylint: disable=broad-except
print(f"osslsigncode error: {err}") print(f"osslsigncode error: {err}")
ret = 1
finally: finally:
server.shut_down() server.shut_down()
sys.exit(ret) sys.exit(ret)