From ea1698499f1f1b73aedd8a627a576f4347495414 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 18 Sep 2019 10:18:49 +0100 Subject: through error when fediverse server is configured but crypto is missing --- modules/fediverse/ap_security.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules/fediverse/ap_security.py') diff --git a/modules/fediverse/ap_security.py b/modules/fediverse/ap_security.py index 1ffd3fdb..391c58de 100644 --- a/modules/fediverse/ap_security.py +++ b/modules/fediverse/ap_security.py @@ -1,12 +1,16 @@ import base64, typing -from cryptography.hazmat.primitives import hashes, serialization -from cryptography.hazmat.primitives.asymmetric import padding, rsa -from cryptography.hazmat.backends import default_backend + +try: + from cryptography.hazmat.primitives import hashes, serialization + from cryptography.hazmat.primitives.asymmetric import padding, rsa + from cryptography.hazmat.backends import default_backend + has_crypto = True +except ModuleNotFoundError: + has_crypto = False SIGNATURE_FORMAT = ( "keyId=\"%s\",headers=\"%s\",signature=\"%s\",algorithm=\"rsa-sha256\"") - def _private_key(key_filename: str) -> rsa.RSAPrivateKey: with open(key_filename, "rb") as key_file: return serialization.load_pem_private_key( -- cgit v1.3.1-10-gc9f91