Bug 1736453 - Update pysign.py to work under python 3. r=keeler
authorBryce Seager van Dyk <bvandyk@mozilla.com>
Tue, 19 Oct 2021 15:06:58 +0000
changeset 596363 3f145a672ed6f752054d408fa32f6c781aaec6f1
parent 596362 46ed5b6367a142a6a3fdc56e53ff32fbb234522c
child 596364 5243c0c312339bb42709453c8b27afbfeef56795
push id38896
push userabutkovits@mozilla.com
push dateTue, 19 Oct 2021 21:51:00 +0000
treeherdermozilla-central@e9071741b84c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1736453
milestone95.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1736453 - Update pysign.py to work under python 3. r=keeler This also fixes the relative path to pykey.py, which appears to have changed since the script was first written. Differential Revision: https://phabricator.services.mozilla.com/D128797
security/manager/ssl/tests/unit/test_content_signing/pysign.py
--- a/security/manager/ssl/tests/unit/test_content_signing/pysign.py
+++ b/security/manager/ssl/tests/unit/test_content_signing/pysign.py
@@ -13,23 +13,24 @@ The certificates for the content signatu
 You can use pysign.py like this:
 
 cat test.txt | python pysign.py > test.txt.signature
 """
 
 import base64
 import binascii
 import hashlib
-import os
+import pathlib
 import six
 import sys
 
 import ecdsa
 
-# For pykey
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+# For pykey, find the relative file location and add it to path
+toolsDir = (pathlib.Path(__file__).parents[4] / "tools").resolve()
+sys.path.append(str(toolsDir))
 import pykey
 
 data = sys.stdin.buffer.read()
 
 key = pykey.ECCKey("secp384r1")
 sig = key.signRaw(b"Content-Signature:\00" + data, pykey.HASH_SHA384)
-print base64.b64encode(sig).replace("+", "-").replace("/", "_")
+print(str(base64.b64encode(sig)).replace("+", "-").replace("/", "_"))