aboutsummaryrefslogtreecommitdiff
path: root/modules/fediverse/ap_security.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/fediverse/ap_security.py')
-rw-r--r--modules/fediverse/ap_security.py12
1 files changed, 8 insertions, 4 deletions
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(