From d5b7e0ebdbcd70315ed249ac7be7ebc75266e4f5 Mon Sep 17 00:00:00 2001 From: Austin Crandall <79296037+sevenrats@users.noreply.github.com> Date: Thu, 1 Jun 2023 14:09:38 -0400 Subject: [PATCH] unify setCertificates functionality (#1282) Co-authored-by: Charles Ewert --- components/ItemGrid/LoadVideoContentTask.brs | 2 +- source/VideoPlayer.brs | 2 +- source/api/baserequest.brs | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/ItemGrid/LoadVideoContentTask.brs b/components/ItemGrid/LoadVideoContentTask.brs index 1fcbf302..23d5403b 100644 --- a/components/ItemGrid/LoadVideoContentTask.brs +++ b/components/ItemGrid/LoadVideoContentTask.brs @@ -180,7 +180,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s video.isTranscoded = true end if - video.content.setCertificatesFile("common:/certs/ca-bundle.crt") + setCertificateAuthority(video.content) video.audioTrack = (audio_stream_idx + 1).ToStr() ' Roku's track indexes count from 1. Our index is zero based video.SelectedSubtitle = subtitle_idx diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs index 89e9c6fa..e30d1a6c 100644 --- a/source/VideoPlayer.brs +++ b/source/VideoPlayer.brs @@ -304,7 +304,7 @@ sub AddVideoContent(video as object, mediaSourceId as dynamic, audio_stream_idx video.isTranscoded = true end if - video.content.setCertificatesFile("common:/certs/ca-bundle.crt") + setCertificateAuthority(video.content) video.audioTrack = (audio_stream_idx + 1).ToStr() ' Roku's track indexes count from 1. Our index is zero based ' Perform relevant setup work for selected subtitle, and return the index of the subtitle diff --git a/source/api/baserequest.brs b/source/api/baserequest.brs index e1882b60..c88ea7c8 100644 --- a/source/api/baserequest.brs +++ b/source/api/baserequest.brs @@ -65,7 +65,7 @@ function APIRequest(url as string, params = {} as object) as dynamic req = authorize_request(req) ' SSL cert if serverURL.left(8) = "https://" - req.setCertificatesFile("common:/certs/ca-bundle.crt") + setCertificateAuthority(req) end if return req @@ -189,6 +189,11 @@ function postString(req, data = "" as string) return resp.getString() end function +' sets the certificate authority by file path on the passed node +sub setCertificateAuthority(request as object) as void + request.setCertificatesFile("common:/certs/ca-bundle.crt") +end sub + function authorize_request(request) auth = "MediaBrowser" + " Client=" + Chr(34) + "Jellyfin Roku" + Chr(34) auth = auth + ", Device=" + Chr(34) + m.global.device.name + " (" + m.global.device.friendlyName + ")" + Chr(34)