Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/x509/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ X.509 CRL (Certificate Revocation List) Object
.. doctest::

>>> crl.issuer
<Name(C=US,CN=cryptography.io)>
<Name(CN=cryptography.io,C=US)>

.. attribute:: next_update

Expand Down
3 changes: 1 addition & 2 deletions src/cryptography/x509/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ def __len__(self) -> int:
return sum(len(rdn) for rdn in self._attributes)

def __repr__(self) -> str:
rdns = ",".join(attr.rfc4514_string() for attr in self._attributes)
return f"<Name({rdns})>"
return f"<Name({self.rfc4514_string()})>"


class _RFC4514NameParser:
Expand Down
16 changes: 8 additions & 8 deletions tests/x509/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,15 +1694,15 @@ def test_public_bytes_match(
serialized = cert.public_bytes(encoding)
assert serialized == cert_bytes

def test_certificate_repr(self, backend):
def test_certificate_repr(self):
cert = _load_cert(
os.path.join("x509", "cryptography.io.pem"),
x509.load_pem_x509_certificate,
)
assert repr(cert) == (
"<Certificate(subject=<Name(OU=GT48742965,OU=See www.rapidssl.com"
"/resources/cps (c)14,OU=Domain Control Validated - RapidSSL(R),"
"CN=www.cryptography.io)>, ...)>"
"<Certificate(subject=<Name(CN=www.cryptography.io,OU=Domain "
"Control Validated - RapidSSL(R),OU=See "
"www.rapidssl.com/resources/cps (c)14,OU=GT48742965)>, ...)>"
)

def test_parse_tls_feature_extension(self, backend):
Expand Down Expand Up @@ -5790,7 +5790,7 @@ def test_load_ecdsa_cert_null_alg_params(self, backend):
assert isinstance(cert.signature_hash_algorithm, hashes.SHA256)
assert isinstance(cert.public_key(), ec.EllipticCurvePublicKey)

def test_load_bitstring_dn(self, backend):
def test_load_bitstring_dn(self):
cert = _load_cert(
os.path.join("x509", "scottishpower-bitstring-dn.pem"),
x509.load_pem_x509_certificate,
Expand All @@ -5809,7 +5809,7 @@ def test_load_bitstring_dn(self, backend):
]
)
assert repr(cert.subject) == (
"<Name(CN=ScottishPower,OU=02,2.5.4.45=#0070b3d51f305f0001)>"
"<Name(2.5.4.45=#0070b3d51f305f0001,OU=02,CN=ScottishPower)>"
)

def test_load_name_attribute_long_form_asn1_tag(self, backend):
Expand Down Expand Up @@ -6409,12 +6409,12 @@ def test_rdns(self):
(
"cryptography.io",
"PyCA",
"<Name(CN=cryptography.io,O=PyCA)>",
"<Name(O=PyCA,CN=cryptography.io)>",
),
(
"Certificación",
"Certificación",
"<Name(CN=Certificación,O=Certificación)>",
"<Name(O=Certificación,CN=Certificación)>",
),
],
)
Expand Down
Loading