diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/x509.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index 7b9f71cd..a470adbd 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function import datetime import ipaddress +import operator from email.utils import parseaddr @@ -872,8 +873,16 @@ class _CertificateRevocationList(object): yield self._revoked_cert(i) def __getitem__(self, idx): - # TODO: indexing is O(n) - return list(self)[idx] + if isinstance(idx, slice): + start, stop, step = idx.indices(len(self)) + return [self._revoked_cert(i) for i in range(start, stop, step)] + else: + idx = operator.index(idx) + if idx < 0: + idx += len(self) + if not 0 <= idx < len(self): + raise IndexError + return self._revoked_cert(idx) def __len__(self): revoked = self._backend._lib.X509_CRL_get_REVOKED(self._x509_crl) |