aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cryptography/x509/extensions.py3
-rw-r--r--tests/x509/test_x509_ext.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index eb4b927f..af12fa9c 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -1160,6 +1160,9 @@ class Extension(object):
class GeneralNames(object):
def __init__(self, general_names):
general_names = list(general_names)
+ if len(general_names) == 0:
+ raise ValueError("Must supply at least one general name")
+
if not all(isinstance(x, GeneralName) for x in general_names):
raise TypeError(
"Every item in the general_names list must be an "
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py
index 9f4e1758..b048c140 100644
--- a/tests/x509/test_x509_ext.py
+++ b/tests/x509/test_x509_ext.py
@@ -2052,6 +2052,10 @@ class TestGeneralNames(object):
[x509.DNSName(u"cryptography.io"), "invalid"]
)
+ def test_does_not_allow_empty_list(self):
+ with pytest.raises(ValueError):
+ x509.GeneralNames([])
+
def test_repr(self):
gns = x509.GeneralNames(
[