aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-08-04 23:31:15 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-08-04 23:31:15 -0400
commit2fe409eb008acdfe598386f7f17a502a535e5864 (patch)
tree8450f3b4ab4a1526cd9624a4d3e1b3be1818ec97 /src
parentda0bad39ceda2ed5a8c351602183ebb67fcbea20 (diff)
parent7d792fcf713927424e26e7cd1347cb197f658792 (diff)
downloadcryptography-2fe409eb008acdfe598386f7f17a502a535e5864.tar.gz
cryptography-2fe409eb008acdfe598386f7f17a502a535e5864.tar.bz2
cryptography-2fe409eb008acdfe598386f7f17a502a535e5864.zip
Merge pull request #2202 from reaperhulk/cert-builder-checks
check that required fields are present in builder when signing
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/x509.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py
index 978eb560..0ddff728 100644
--- a/src/cryptography/x509.py
+++ b/src/cryptography/x509.py
@@ -1752,4 +1752,22 @@ class CertificateBuilder(object):
"""
Signs the certificate using the CA's private key.
"""
+ if self._subject_name is None:
+ raise ValueError("A certificate must have a subject name")
+
+ if self._issuer_name is None:
+ raise ValueError("A certificate must have an issuer name")
+
+ if self._serial_number is None:
+ raise ValueError("A certificate must have a serial number")
+
+ if self._not_valid_before is None:
+ raise ValueError("A certificate must have a not valid before time")
+
+ if self._not_valid_after is None:
+ raise ValueError("A certificate must have a not valid after time")
+
+ if self._public_key is None:
+ raise ValueError("A certificate must have a public key")
+
return backend.sign_x509_certificate(self, private_key, algorithm)