diff options
| author | 2019-09-18 10:18:49 +0100 | |
|---|---|---|
| committer | 2019-09-18 10:18:49 +0100 | |
| commit | ea1698499f1f1b73aedd8a627a576f4347495414 (patch) | |
| tree | 426a50d563efbbeff4fcf59aafda2469e4cafaa3 /modules/fediverse/ap_security.py | |
| parent | add :$port to nginx Host header (diff) | |
through error when fediverse server is configured but crypto is missing
Diffstat (limited to 'modules/fediverse/ap_security.py')
| -rw-r--r-- | modules/fediverse/ap_security.py | 12 |
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( |
