diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-08-12 10:57:38 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-08-12 10:57:38 -0500 |
commit | 0a12276df5db502927f9aaa8117ea746bf29f9f0 (patch) | |
tree | 9195d6410196e2376142ae3182c66f3224178cfe /src | |
parent | 0998a1a6a3f390a40b74f2cb3fbb36cb07e9c63e (diff) | |
parent | cb5ec4e90ea06d0b5ee95c68c26927ab7623b588 (diff) | |
download | cryptography-0a12276df5db502927f9aaa8117ea746bf29f9f0.tar.gz cryptography-0a12276df5db502927f9aaa8117ea746bf29f9f0.tar.bz2 cryptography-0a12276df5db502927f9aaa8117ea746bf29f9f0.zip |
Merge pull request #2267 from queenp/iss2255
added get_extension_for_class #2255
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/x509/extensions.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index 798a0e3a..803d7ec5 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -89,6 +89,15 @@ class Extensions(object): raise ExtensionNotFound("No {0} extension was found".format(oid), oid) + def get_extension_for_class(self, extclass): + for ext in self: + if isinstance(ext.value, extclass): + return ext + + raise ExtensionNotFound( + "No {0} extension was found".format(extclass), extclass.oid + ) + def __iter__(self): return iter(self._extensions) |