summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2024-04-01 22:29:22 +0100
committerJames Le Cuirot <chewi@gentoo.org>2024-04-01 22:30:06 +0100
commit40e2f08af0ed429d2369e2c183782e42550234e8 (patch)
treef3128a37b44c280a7948ba64d23fe3b028bfcdd5 /dev-python/aiopylgtv
parentapp-misc/gnote: drop 45.0, 45.1 (diff)
downloadgentoo-40e2f08af0ed429d2369e2c183782e42550234e8.tar.gz
gentoo-40e2f08af0ed429d2369e2c183782e42550234e8.tar.bz2
gentoo-40e2f08af0ed429d2369e2c183782e42550234e8.zip
dev-python/aiopylgtv: Patch to use WSS, as required by newer TV firmware
The patch has been submitted upstream, but upstream is dead. I'll switch to a different fork soon. Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'dev-python/aiopylgtv')
-rw-r--r--dev-python/aiopylgtv/aiopylgtv-0.4.1-r1.ebuild (renamed from dev-python/aiopylgtv/aiopylgtv-0.4.1.ebuild)9
-rw-r--r--dev-python/aiopylgtv/files/aiopylgtv-0.4.1-ssl.patch124
2 files changed, 131 insertions, 2 deletions
diff --git a/dev-python/aiopylgtv/aiopylgtv-0.4.1.ebuild b/dev-python/aiopylgtv/aiopylgtv-0.4.1-r1.ebuild
index 46580be5880b..941faa54bb8b 100644
--- a/dev-python/aiopylgtv/aiopylgtv-0.4.1.ebuild
+++ b/dev-python/aiopylgtv/aiopylgtv-0.4.1-r1.ebuild
@@ -1,9 +1,10 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-PYTHON_COMPAT=( python3_{9..11} )
+PYTHON_COMPAT=( python3_{9..12} )
+PYTHON_REQ_USE="ssl"
DISTUTILS_USE_PEP517="setuptools"
inherit distutils-r1 pypi
@@ -21,3 +22,7 @@ RDEPEND="
dev-python/sqlitedict[${PYTHON_USEDEP}]
>=dev-python/websockets-8.1[${PYTHON_USEDEP}]
"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-ssl.patch
+)
diff --git a/dev-python/aiopylgtv/files/aiopylgtv-0.4.1-ssl.patch b/dev-python/aiopylgtv/files/aiopylgtv-0.4.1-ssl.patch
new file mode 100644
index 000000000000..aef88f399e6b
--- /dev/null
+++ b/dev-python/aiopylgtv/files/aiopylgtv-0.4.1-ssl.patch
@@ -0,0 +1,124 @@
+From 87e1447d1fc6e6db9a9e6bc9c8b5241b149cf6dd Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Sat, 14 Oct 2023 18:01:52 +0100
+Subject: [PATCH] Use WSS (SSL) connection as firmware update has removed
+ non-SSL support
+
+Closes: https://github.com/bendavid/aiopylgtv/issues/65
+---
+ aiopylgtv/lg-ca.pem | 34 ++++++++++++++++++++++++++++++++++
+ aiopylgtv/webos_client.py | 17 +++++++++++++++--
+ setup.py | 1 +
+ 3 files changed, 50 insertions(+), 2 deletions(-)
+ create mode 100644 aiopylgtv/lg-ca.pem
+
+diff --git a/aiopylgtv/lg-ca.pem b/aiopylgtv/lg-ca.pem
+new file mode 100644
+index 0000000..05df860
+--- /dev/null
++++ b/aiopylgtv/lg-ca.pem
+@@ -0,0 +1,34 @@
++-----BEGIN CERTIFICATE-----
++MIIF+TCCA+GgAwIBAgICEAcwDQYJKoZIhvcNAQELBQAwgacxCzAJBgNVBAYTAktS
++MQ4wDAYDVQQIDAVTZW91bDEOMAwGA1UEBwwFU2VvdWwxHDAaBgNVBAoME0xHIEVs
++ZWN0cm9uaWNzIEluYy4xFjAUBgNVBAsMDUhFIExhYm9yYXRvcnkxHDAaBgNVBAMM
++E0xHIHdlYk9TIFRWIFJvb3QgQ0ExJDAiBgkqhkiG9w0BCQEWFXNlY3VyaXR5LXBh
++cnRAbGdlLmNvbTAeFw0xODAzMTIwMTMwMjhaFw0zNDA4MTUwMTMwMjhaMG8xCzAJ
++BgNVBAYTAktSMQ4wDAYDVQQIDAVTZW91bD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7QrxLJN+hJh2Go
++f/NO6p9v0REoNeQjVKXbd8ycNpOl5SY620XFip6F+gLGxlTRy2LX7BUpYwCHoAuD
++zSdRi7bhqmdwSZL7VGwm4RIGpeUWNqx2YH8xgJ7Zb4v0LCcCDsqB1JdobxB1ULbB
++ZQ/8BsuEjiWnWg0nTDz7VZmpP1fOs4vLYPzFVzq07Q9avxYh642JLshhVZ9/VwWL
++q5uGXNrxrvRNr4JR5emax9HV/o+LK9FdUP5XJWEXeXSRSvCYh7djtkQqzcmLdT4x
++zU6chJMuCJAG6qzv8r7EA0IrbWk5oBhxNet/cCExIUH/Rqivcfa7qPTsTYVSoM5J
++dw2ociET6vc2UmYzBiHV22Ez02aydOSmL4VkdR+ngxGTaCkEDBpHPLDaZ6Yzp/xB
++gCGkvL417B3rTuBvD2YYwQ2pSS9O5N0FOLFjX3L3d9ixlXwqWi07w79YONjLqjYm
++6OrYp5xtinZrxEEcdu/jt0pSOkYVG+NEg+kcLiRpxy4q7A3vVllREbLZL6R/5G3D
++ulTRmICailJN3PF+5YavaQI2H6yRdiw2OMzaLgHw3zU9NGN43mMI1q1Yl4PYA2sO
++qHkaceoSAL7CaC2ZvI51K88ekUfqC34L20hiZS8kLtE3BLS/olqMsyuAnBc+
++-----END CERTIFICATE-----
+diff --git a/aiopylgtv/webos_client.py b/aiopylgtv/webos_client.py
+index 6649dc5..8d20a22 100644
+--- a/aiopylgtv/webos_client.py
++++ b/aiopylgtv/webos_client.py
+@@ -5,7 +5,9 @@ import functools
+ import json
+ import logging
+ import os
++import ssl
+ from datetime import timedelta
++from importlib.resources import files
+
+ import numpy as np
+ import websockets
+@@ -66,7 +68,7 @@ class WebOsClient:
+ ):
+ """Initialize the client."""
+ self.ip = ip
+- self.port = 3000
++ self.port = 3001
+ self.key_file_path = key_file_path
+ self.client_key = client_key
+ self.web_socket = None
+@@ -188,12 +190,22 @@ class WebOsClient:
+ ws = None
+ inputws = None
+ try:
++ cadata = files("aiopylgtv").joinpath("lg-ca.pem").read_text(encoding="ascii")
++
++ ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
++ ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
++ ssl_context.verify_mode = ssl.CERT_REQUIRED
++ ssl_context.verify_flags |= ssl.VERIFY_X509_PARTIAL_CHAIN
++ ssl_context.load_verify_locations(cadata=cadata)
++ ssl_context.check_hostname = False
++
+ ws = await asyncio.wait_for(
+ websockets.connect(
+- f"ws://{self.ip}:{self.port}",
++ f"wss://{self.ip}:{self.port}",
+ ping_interval=None,
+ close_timeout=self.timeout_connect,
+ max_size=None,
++ ssl=ssl_context,
+ ),
+ timeout=self.timeout_connect,
+ )
+@@ -242,6 +254,7 @@ class WebOsClient:
+ inputsockpath,
+ ping_interval=None,
+ close_timeout=self.timeout_connect,
++ ssl=ssl_context,
+ ),
+ timeout=self.timeout_connect,
+ )
+diff --git a/setup.py b/setup.py
+index 306a7d4..a7f67ef 100644
+--- a/setup.py
++++ b/setup.py
+@@ -6,6 +6,7 @@ with open("README.md") as f:
+ setup(
+ name="aiopylgtv",
+ packages=["aiopylgtv"],
++ package_data={"aiopylgtv": ["*.pem"]},
+ install_requires=["websockets>=8.1", "numpy>=1.17.0", "sqlitedict"],
+ python_requires=">=3.7",
+ zip_safe=True,
+--
+2.41.0
+