summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-11-27 07:08:40 -1000
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-15 15:49:48 -0600
commita68fd33ca8518a734b655457eca9ab28ccbcb7bb (patch)
tree3af34fc45521f6b9dba216a7959447512c6a1e9d
parentf1ef351362da9913f53fec73b68e188533036b4e (diff)
downloadcryptography-a68fd33ca8518a734b655457eca9ab28ccbcb7bb.tar.gz
address review feedback
-rw-r--r--docs/exceptions.rst5
-rw-r--r--docs/x509.rst7
-rw-r--r--src/cryptography/exceptions.py4
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py5
-rw-r--r--src/cryptography/x509.py4
-rw-r--r--tests/test_x509.py7
6 files changed, 15 insertions, 17 deletions
diff --git a/docs/exceptions.rst b/docs/exceptions.rst
index b86d3eea5..28da8ecc1 100644
--- a/docs/exceptions.rst
+++ b/docs/exceptions.rst
@@ -43,8 +43,3 @@ Exceptions
This is raised when the verify method of a one time password function's
computed token does not match the expected token.
-
-
-.. class:: InvalidX509Version
-
- This is raised when an X.509 certificate has an invalid version number.
diff --git a/docs/x509.rst b/docs/x509.rst
index 2c9c0f461..ba52d91a0 100644
--- a/docs/x509.rst
+++ b/docs/x509.rst
@@ -6,7 +6,8 @@ X.509
.. currentmodule:: cryptography.x509
X.509 is an ITU-T standard for a `public key infrastructure`_. X.509v3 is
-defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`).
+defined in :rfc:`5280` (which obsoletes :rfc:`2459` and :rfc:`3280`). X.509
+certificates are commonly used in protocols like `TLS`_.
Loading
~~~~~~~
@@ -92,6 +93,10 @@ Support Classes
For version 3 X.509 certificates.
+.. class:: InvalidX509Version
+
+ This is raised when an X.509 certificate has an invalid version number.
.. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure
+.. _`TLS`: https://en.wikipedia.org/wiki/Transport_Layer_Security
diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py
index 23edcd02d..b0e1a9935 100644
--- a/src/cryptography/exceptions.py
+++ b/src/cryptography/exceptions.py
@@ -53,7 +53,3 @@ class InvalidKey(Exception):
class InvalidToken(Exception):
pass
-
-
-class InvalidX509Version(Exception):
- pass
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 9f6f71d0d..6befc3cfc 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -16,7 +16,6 @@ from __future__ import absolute_import, division, print_function
import datetime
from cryptography import utils, x509
-from cryptography.exceptions import InvalidX509Version
from cryptography.hazmat.primitives import hashes, interfaces
@@ -61,8 +60,8 @@ class _X509Certificate(object):
elif version == 2:
return x509.X509Version.v3
else:
- raise InvalidX509Version(
- "{0} is not a valid X509 version", version
+ raise x509.InvalidX509Version(
+ "{0} is not a valid X509 version".format(version)
)
@property
diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py
index f3c73d6b4..191666e6f 100644
--- a/src/cryptography/x509.py
+++ b/src/cryptography/x509.py
@@ -18,3 +18,7 @@ def load_pem_x509_certificate(data, backend):
def load_der_x509_certificate(data, backend):
return backend.load_der_x509_certificate(data)
+
+
+class InvalidX509Version(Exception):
+ pass
diff --git a/tests/test_x509.py b/tests/test_x509.py
index f50a82ae2..df27f8d01 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -10,7 +10,6 @@ import os
import pytest
from cryptography import x509
-from cryptography.exceptions import InvalidX509Version
from cryptography.hazmat.backends.interfaces import (
DSABackend, EllipticCurveBackend, RSABackend, X509Backend
)
@@ -43,7 +42,7 @@ class TestRSAX509Certificate(object):
pemfile.read(), backend
)
)
- assert cert
+ assert isinstance(cert, interfaces.X509Certificate)
def test_load_der_cert(self, backend):
cert = load_vectors_from_file(
@@ -53,7 +52,7 @@ class TestRSAX509Certificate(object):
derfile.read(), backend
)
)
- assert cert
+ assert isinstance(cert, interfaces.X509Certificate)
def test_load_good_ca_cert(self, backend):
cert = _load_der_cert("GoodCACert.crt", backend)
@@ -117,7 +116,7 @@ class TestRSAX509Certificate(object):
pemfile.read(), backend
)
)
- with pytest.raises(InvalidX509Version):
+ with pytest.raises(x509.InvalidX509Version):
cert.version
def test_version_1_cert(self, backend):