acmecert: Fix cryptography bugs. master
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 28 Jul 2023 10:03:19 +0000 (12:03 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 28 Jul 2023 10:03:19 +0000 (12:03 +0200)
acmecert

index 84c212a..14d0f00 100755 (executable)
--- a/acmecert
+++ b/acmecert
@@ -462,8 +462,9 @@ def mkorder(acct, csr):
 
 def httptoken(acct, ch):
     from cryptography.hazmat.primitives import hashes
-    jwk = {"kty": "RSA", "e": ebignum(acct.key.e), "n": ebignum(acct.key.n)}
-    dig = hashes.Hash(hashes.SHA256())
+    pub = acct.key.public_key().public_numbers()
+    jwk = {"kty": "RSA", "e": ebignum(pub.e), "n": ebignum(pub.n)}
+    dig = hashes.Hash(hashes.SHA256(), backend=cryptobke())
     dig.update(json.dumps(jwk, separators=(',', ':'), sort_keys=True).encode("us-ascii"))
     khash = base64url(dig.finalize())
     return ch["token"], ("%s.%s" % (ch["token"], khash))