Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS client authentication #426

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jellyfin_mpv_shim/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def client_factory():
)
client.config.data["http.user_agent"] = USER_AGENT
client.config.data["auth.ssl"] = not settings.ignore_ssl_cert
client.config.data["auth.tls_client_cert"] = settings.tls_client_cert
client.config.data["auth.tls_client_key"] = settings.tls_client_key
client.config.data["auth.tls_server_ca"] = settings.tls_server_ca
client.auth.create_session_with_client_auth()
return client

def _connect_all(self):
Expand Down
3 changes: 3 additions & 0 deletions jellyfin_mpv_shim/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class Settings(SettingsBase):
thumbnail_enable: bool = True
thumbnail_osc_builtin: bool = True
thumbnail_preferred_size: int = 320
tls_client_cert: Optional[str] = None
tls_client_key: Optional[str] = None
tls_server_ca: Optional[str] = None

def __get_file(self, path: str, mode: str = "r", create: bool = True):
created = False
Expand Down
8 changes: 8 additions & 0 deletions jellyfin_mpv_shim/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ def __init__(self):
mpv_options["config"] = True
mpv_options["config_dir"] = conffile.confdir(APP_NAME)

if settings.tls_client_cert and settings.tls_client_key:
mpv_options['tls_cert_file'] = settings.tls_client_cert
mpv_options['tls_key_file'] = settings.tls_client_key

if settings.tls_server_ca:
mpv_options['tls_ca_file'] = settings.tls_server_ca

self._player = mpv.MPV(
input_default_bindings=True,
input_vo_keyboard=True,
Expand All @@ -210,6 +217,7 @@ def __init__(self):
loglevel=settings.mpv_log_level,
**mpv_options,
)

self.menu = OSDMenu(self, self._player)
self.syncplay = SyncPlayManager(self)

Expand Down