aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhoebe Queen <foibey@gmail.com>2015-08-12 02:15:08 +0100
committerPhoebe Queen <foibey@gmail.com>2015-08-12 02:15:08 +0100
commitdb34d7e3d9e6b13e549866324323e1df8a6e7777 (patch)
tree0c5fced88f92ac81312dc0a82ea1cfcf834fbfc9 /src
parentb229eb3b2a95677c42bd63a8df8f1a756cf771e0 (diff)
downloadcryptography-db34d7e3d9e6b13e549866324323e1df8a6e7777.tar.gz
cryptography-db34d7e3d9e6b13e549866324323e1df8a6e7777.tar.bz2
cryptography-db34d7e3d9e6b13e549866324323e1df8a6e7777.zip
added get_extension_for_class #2255
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/x509/base.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cryptography/x509/base.py b/src/cryptography/x509/base.py
index 2b4eeb56..f58b5221 100644
--- a/src/cryptography/x509/base.py
+++ b/src/cryptography/x509/base.py
@@ -79,6 +79,13 @@ 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 type(ext.value) == extclass:
+ return ext
+
+ raise ExtensionNotFound("No {0} extension was found".format(extclass), extclass)
+
def __iter__(self):
return iter(self._extensions)