Skip to content

E2EE: EncodeError when connecting with encryption enabled #606

Closed

Description

@Uldiniad

When connecting with E2EE enabled via E2EEOptions(key_provider_options=KeyProviderOptions(shared_key=...)), the connect call fails with a protobuf EncodeError.

The cause appears to be that key_ring_size and key_derivation_function on the KeyProviderOptions proto message are never populated. They're required fields in the proto2 schema but aren't exposed on the Python KeyProviderOptions dataclass and aren't set in room.py's connect() method.

This affects both the options.e2ee and options.encryption code paths.

We're currently working around this by monkey-patching the FFI request to set defaults before it's sent.

from livekit.rtc._ffi_client import FfiClient
from livekit.rtc._proto import ffi_pb2 as _proto_ffi

_original_ffi_request = FfiClient.request


def _patched_ffi_request(
    self: FfiClient, req: _proto_ffi.FfiRequest
) -> _proto_ffi.FfiResponse:
    if req.HasField("connect"):
        for field_name in ("encryption", "e2ee"):
            if req.connect.options.HasField(field_name):
                kpo = getattr(req.connect.options, field_name).key_provider_options
                if not kpo.key_ring_size:
                    kpo.key_ring_size = 16
                if not kpo.key_derivation_function:
                    kpo.key_derivation_function = 0
    return _original_ffi_request(self, req)


FfiClient.request = _patched_ffi_request  # type: ignore[assignment]

Activity

  1. trippyogi commented on Jul 16, 2026

    @trippyogi

    This appears fixed by #628 (merge commit 1dfb135).

    That PR sets the required protobuf fields that were missing on KeyProviderOptions:

    • key_ring_size (default 16)
    • key_derivation_function (default PBKDF2)

    Both options.e2ee and options.encryption paths in Room.connect() now copy these fields. The fix first shipped in livekit-rtc rtc-v1.1.6.

    If maintainers agree, please close this issue. Happy to provide more detail if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions