def parse_certificate_object_identifier_name(certificate: x509.Name, oid: x509.ObjectIdentifier) -> Optional[List[str]]: """ Get attribute from decoded certificate. Args: certificate: Certificate as x509.Certificate . oid: Enum value from x509.NameOID . Returns: list: Decoded values. """ attributes = [attr.value for attr in certificate.get_attributes_for_oid(oid)] return attributes if attributes else None
def get_common_names(name_field: x509.Name) -> List[str]: return [cn.value for cn in name_field.get_attributes_for_oid(NameOID.COMMON_NAME)] # type: ignore
def _get_names_with_oid(name_field: Name, name_oid: NameOID) -> List[str]: return [cn.value for cn in name_field.get_attributes_for_oid(name_oid)]