diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-11-13 14:30:11 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-11-13 17:30:11 -0500 |
commit | 3a15b03e92c9fdeadff04ddd2ce505028b279b86 (patch) | |
tree | e314732deed27d3f3f4dba9b4c1f40dcca3e54fa /tests/test_x509.py | |
parent | d862933de5c344fcdf99ab2f43f3bf8da65f3e41 (diff) | |
download | cryptography-3a15b03e92c9fdeadff04ddd2ce505028b279b86.tar.gz cryptography-3a15b03e92c9fdeadff04ddd2ce505028b279b86.tar.bz2 cryptography-3a15b03e92c9fdeadff04ddd2ce505028b279b86.zip |
Add a bytes method to get the DER ASN.1 encoding of an X509 name. (#3236)
* Add a bytes method to get the DER ASN.1 encoding of an X509 name.
This is useful for creating an OpenSSL style subject_name_hash (#3011)
* add to backend interface and update multibackend
* bytes -> public_bytes
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r-- | tests/test_x509.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index f375ac55..5d334242 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -3842,6 +3842,17 @@ class TestName(object): with pytest.raises(TypeError): x509.Name(["not-a-NameAttribute"]) + @pytest.mark.requires_backend_interface(interface=X509Backend) + def test_bytes(self, backend): + name = x509.Name([ + x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'), + x509.NameAttribute(NameOID.ORGANIZATION_NAME, u'PyCA'), + ]) + assert name.public_bytes(backend) == binascii.unhexlify( + b"30293118301606035504030c0f63727970746f6772617068792e696f310d300" + b"b060355040a0c0450794341" + ) + def test_random_serial_number(monkeypatch): sample_data = os.urandom(20) |