fix default backend issue on configuration tool

This commit is contained in:
bunnie 2022-06-05 02:11:37 +08:00
parent 1024cebe55
commit 8fd94f061e

View file

@ -30,6 +30,7 @@ from tqdm.auto import tqdm
from cryptography import x509
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.backends import default_backend
from fido2 import ctap
from fido2 import ctap2
@ -69,7 +70,7 @@ def get_opensk_devices(batch_mode):
def get_private_key(data, password=None):
# First we try without password.
try:
return serialization.load_pem_private_key(data, password=None)
return serialization.load_pem_private_key(data, password=None, backend=default_backend())
except TypeError:
# Maybe we need a password then.
if sys.stdin.isatty():
@ -98,7 +99,7 @@ def main(args):
fatal("Private key must be 256 bits long.")
info("Private key is valid.")
cert = x509.load_pem_x509_certificate(args.certificate.read())
cert = x509.load_pem_x509_certificate(args.certificate.read(), backend=default_backend())
# Some sanity/validity checks
now = datetime.datetime.utcnow()
if cert.not_valid_before > now: