diff options
-rw-r--r-- | src/cryptography/x509.py | 5 | ||||
-rw-r--r-- | tests/test_x509.py | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py index 87028be1..2e2e8512 100644 --- a/src/cryptography/x509.py +++ b/src/cryptography/x509.py @@ -148,6 +148,11 @@ class NameAttribute(object): "oid argument must be an ObjectIdentifier instance." ) + if not isinstance(value, six.text_type): + raise TypeError( + "value argument must be a text type." + ) + self._oid = oid self._value = value diff --git a/tests/test_x509.py b/tests/test_x509.py index a3bed85f..d9aa22db 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -794,6 +794,13 @@ class TestNameAttribute(object): with pytest.raises(TypeError): x509.NameAttribute(None, 'value') + def test_init_bad_value(self): + with pytest.raises(TypeError): + x509.NameAttribute( + x509.ObjectIdentifier('oid'), + b'bytes' + ) + def test_eq(self): assert x509.NameAttribute( x509.ObjectIdentifier('oid'), 'value' |