aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/x509/extensions.py9
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)