mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-24 21:34:41 +03:00
Added crpytomanager typing
This commit is contained in:
parent
8f7421ef9d
commit
46bab75a92
@ -51,6 +51,11 @@ from django.conf import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
|
||||
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey
|
||||
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
|
||||
from cryptography.hazmat.primitives.asymmetric.dh import DHPrivateKey
|
||||
|
||||
class CryptoManager:
|
||||
instance = None
|
||||
@ -194,7 +199,7 @@ class CryptoManager:
|
||||
except Exception: # Error decoding crypted element, return empty one
|
||||
return ''
|
||||
|
||||
def loadPrivateKey(self, rsaKey: str):
|
||||
def loadPrivateKey(self, rsaKey: str) -> typing.Union['RSAPrivateKey', 'DSAPrivateKey', 'DHPrivateKey', 'EllipticCurvePrivateKey']:
|
||||
try:
|
||||
return serialization.load_pem_private_key(
|
||||
settings.RSA_KEY.encode(), password=None, backend=default_backend()
|
||||
|
Loading…
Reference in New Issue
Block a user