BerriAI/litellm · error · TypeError

The provided private key is not an RSA key, which is…

Error message

The provided private key is not an RSA key, which is required for OCI signing.

What it means

Error "The provided private key is not an RSA key, which is required for OCI signing." thrown in BerriAI/litellm.

Solutions

  1. Use an RSA private key for OCI signing; generate one with: openssl genrsa -out oci_key.pem 2048.

When it happens

Trigger: Thrown at litellm/llms/oci/common_utils.py:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e5b89946f0b4de07. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/oci/common_utils.py:123

def build_signature_string(method: str, path: str, headers: dict, signed_headers: list) -> str:
    lines: Final = []
    for header in signed_headers:
        if header == "(request-target)":
            value = f"{method.lower()} {path}"
        else:
            value = headers[header]
        lines.append(f"{header}: {value}")
    return "\n".join(lines)


def load_private_key_from_str(key_str: str) -> Any:
    _require_cryptography()
    key: Final = serialization.load_pem_private_key(
        key_str.encode("utf-8"),
        password=None,
    )
    if not isinstance(key, rsa.RSAPrivateKey):
        raise TypeError("The provided private key is not an RSA key, which is required for OCI signing.")
    return key


def load_private_key_from_file(file_path: str) -> Any:
    """Loads a private key from a file path."""
    try:
        with open(file_path, "r", encoding="utf-8") as f:
            key_str: Final = f.read().strip()
    except FileNotFoundError:
        raise FileNotFoundError(f"Private key file not found: {file_path}")
    except OSError as e:
        raise OSError(f"Failed to read private key file '{file_path}': {e}") from e

    if not key_str:
        raise ValueError(f"Private key file is empty: {file_path}")

    return load_private_key_from_str(key_str)

View on GitHub (pinned to 77b7c6c40c)