def check_client(config, client_dn):
    """Check if client dn is in whitelist"""
    # If config is None then all clients are not allowed
    if config is None:
        return False
    if config.get('allow_all', False) is True:
        return True

    allowed = config.get('allowed')
    if client_dn is None or not isinstance(allowed, list):
        return False

    if client_dn in allowed:
        return True

    return False