def try_get_dn_part(subject, oid=None):
    """
    Tries to extracts the OID from the X500 name.
    :param subject:
    :param oid:
    :return:
    """
    try:
        if subject is None:
            return None
        if oid is None:
            return None
        for sub in subject:
            if oid is not None and sub.oid == oid:
                return sub.value
    except:
        pass
    return None
