diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-11-26 09:55:40 -1000 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-11-26 17:06:02 -1000 |
commit | ae8156f1812c28e0265ed3215291be469aa4fd05 (patch) | |
tree | 934438de73063c1ed7f99ba365df5d3e84592025 /src | |
parent | 77f457e734a6882b27a93483b8f0494aabe860b9 (diff) | |
download | cryptography-ae8156f1812c28e0265ed3215291be469aa4fd05.tar.gz cryptography-ae8156f1812c28e0265ed3215291be469aa4fd05.tar.bz2 cryptography-ae8156f1812c28e0265ed3215291be469aa4fd05.zip |
add X509Backend support to multibackend
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/exceptions.py | 1 | ||||
-rw-r--r-- | src/cryptography/hazmat/backends/multibackend.py | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py index 4270cb22..b0e1a993 100644 --- a/src/cryptography/exceptions.py +++ b/src/cryptography/exceptions.py @@ -14,6 +14,7 @@ class _Reasons(object): UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object() UNSUPPORTED_ELLIPTIC_CURVE = object() UNSUPPORTED_SERIALIZATION = object() + UNSUPPORTED_X509 = object() class UnsupportedAlgorithm(Exception): diff --git a/src/cryptography/hazmat/backends/multibackend.py b/src/cryptography/hazmat/backends/multibackend.py index fce6c8e1..ffc569f4 100644 --- a/src/cryptography/hazmat/backends/multibackend.py +++ b/src/cryptography/hazmat/backends/multibackend.py @@ -12,7 +12,7 @@ from cryptography.hazmat.backends.interfaces import ( CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, HashBackend, PBKDF2HMACBackend, PEMSerializationBackend, PKCS8SerializationBackend, RSABackend, - TraditionalOpenSSLSerializationBackend + TraditionalOpenSSLSerializationBackend, X509Backend ) @@ -27,6 +27,7 @@ from cryptography.hazmat.backends.interfaces import ( @utils.register_interface(DSABackend) @utils.register_interface(EllipticCurveBackend) @utils.register_interface(PEMSerializationBackend) +@utils.register_interface(X509Backend) class MultiBackend(object): name = "multibackend" @@ -347,3 +348,25 @@ class MultiBackend(object): "This backend does not support this key serialization.", _Reasons.UNSUPPORTED_SERIALIZATION ) + + def load_pem_x509_certificate(self, data): + for b in self._filtered_backends( + X509Backend + ): + return b.load_pem_x509_certificate(data) + + raise UnsupportedAlgorithm( + "This backend does not support X.509.", + _Reasons.UNSUPPORTED_X509 + ) + + def load_der_x509_certificate(self, data): + for b in self._filtered_backends( + X509Backend + ): + return b.load_der_x509_certificate(data) + + raise UnsupportedAlgorithm( + "This backend does not support X.509.", + _Reasons.UNSUPPORTED_X509 + ) |