diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-06 19:34:00 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-06 19:34:00 -0500 |
commit | 40087ae7bde2b2455491f98a33c7fef580284ee5 (patch) | |
tree | b00ef56da8ef8272ac62fb6cb8dc5d80df45b197 /src | |
parent | 1c6155a9aa47399ef17f23a169bc1233cec1bec3 (diff) | |
parent | 29affd2d9b50b892334447799eb0c351664b0250 (diff) | |
download | cryptography-40087ae7bde2b2455491f98a33c7fef580284ee5.tar.gz cryptography-40087ae7bde2b2455491f98a33c7fef580284ee5.tar.bz2 cryptography-40087ae7bde2b2455491f98a33c7fef580284ee5.zip |
Merge pull request #2766 from reaperhulk/fix-2665
raise ValueError if > 2 byte value for NameAttribute with CN OID
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/x509/name.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py index 9d93ece1..d62341d7 100644 --- a/src/cryptography/x509/name.py +++ b/src/cryptography/x509/name.py @@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function import six from cryptography import utils -from cryptography.x509.oid import ObjectIdentifier +from cryptography.x509.oid import NameOID, ObjectIdentifier class NameAttribute(object): @@ -22,6 +22,11 @@ class NameAttribute(object): "value argument must be a text type." ) + if oid == NameOID.COUNTRY_NAME and len(value.encode("utf8")) != 2: + raise ValueError( + "Country name must be a 2 character country code" + ) + self._oid = oid self._value = value |