diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-12-30 23:05:37 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-12-30 23:05:37 -0500 |
commit | 5660526e6baadb10a1969a32a2dda3bc14c78133 (patch) | |
tree | 5742a9f386b4dcba97e898fb0825a319df5c33df /src | |
parent | e3a40812e7f686d101d00fbfbba67335af271d80 (diff) | |
parent | e69c5fe0649adcfb1c540c39e2b296ad44cde244 (diff) | |
download | cryptography-5660526e6baadb10a1969a32a2dda3bc14c78133.tar.gz cryptography-5660526e6baadb10a1969a32a2dda3bc14c78133.tar.bz2 cryptography-5660526e6baadb10a1969a32a2dda3bc14c78133.zip |
Merge pull request #2609 from reaperhulk/extension-for-class-exception
don't allow UnrecognizedExtension with get_extension_for_class
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/x509/extensions.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index 0c5b5523..f7b5d7f5 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -91,6 +91,13 @@ class Extensions(object): raise ExtensionNotFound("No {0} extension was found".format(oid), oid) def get_extension_for_class(self, extclass): + if extclass is UnrecognizedExtension: + raise TypeError( + "UnrecognizedExtension can't be used with " + "get_extension_for_class because more than one instance of the" + " class may be present." + ) + for ext in self: if isinstance(ext.value, extclass): return ext |