mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-25 23:21: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__)
|
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:
|
class CryptoManager:
|
||||||
instance = None
|
instance = None
|
||||||
@ -194,7 +199,7 @@ class CryptoManager:
|
|||||||
except Exception: # Error decoding crypted element, return empty one
|
except Exception: # Error decoding crypted element, return empty one
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def loadPrivateKey(self, rsaKey: str):
|
def loadPrivateKey(self, rsaKey: str) -> typing.Union['RSAPrivateKey', 'DSAPrivateKey', 'DHPrivateKey', 'EllipticCurvePrivateKey']:
|
||||||
try:
|
try:
|
||||||
return serialization.load_pem_private_key(
|
return serialization.load_pem_private_key(
|
||||||
settings.RSA_KEY.encode(), password=None, backend=default_backend()
|
settings.RSA_KEY.encode(), password=None, backend=default_backend()
|
||||||
|
Loading…
Reference in New Issue
Block a user