def METHOD_NAME(data, password):
    try:
        key, cert, cas = pkcs12.load_key_and_certificates(
            data, password, default_backend()
        )
        if cert:
            cas.insert(0, cert)
        return key, cas
    except ValueError as e:  # cryptography raises ValueError on wrong password
        raise InvalidPasswordError(e)