Skip to content

Commit da7c802

Browse files
author
Git
committed
Updating python code to best practices.
1 parent 9ee8abd commit da7c802

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

certificate/CertificateDecoder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class CertificateDecoder:
77
CLASS_VERSION = "0.01"
88

99
def decode(self, der_cert_bytes: bytes) -> dict:
10+
"""This returns the same format as the output of getpeercert()"""
11+
1012
cert = x509.load_der_x509_certificate(der_cert_bytes, default_backend())
1113
return {
1214
"subject": self._parse_name(cert.subject),
@@ -22,12 +24,16 @@ def decode(self, der_cert_bytes: bytes) -> dict:
2224
}
2325

2426
def _parse_name(self, name: x509.Name) -> Tuple[Tuple[Tuple[str, str], ...], ...]:
27+
"""This will iterate over the values."""
28+
2529
return tuple(
2630
tuple((attr.oid._name, attr.value) for attr in rdn)
2731
for rdn in name.rdns # Use .rdns to iterate over RDNs in the Name
2832
)
2933

3034
def _get_extension_value(self, cert: x509.Certificate, ext_type, method: Optional[str] = None) -> Union[Tuple[str, ...], None]:
35+
"""This will iterate through the OCSP, caIssuers, subjectAlternativeNames and CRLDistributionsPoints."""
36+
3137
try:
3238
ext = cert.extensions.get_extension_for_class(ext_type)
3339
if method == 'OCSP':

0 commit comments

Comments
 (0)