Skip to content

Commit 736575d

Browse files
committed
Fix Hitron CODA-56 polling failure on HTTPS with weak certificate
Some CODA-56 units serve HTTPS with certificates using short keys that modern OpenSSL rejects. Add _LegacyTLSAdapter (same pattern as CM8200/SB6190) so the driver works with both HTTP and HTTPS. Fixes #191
1 parent f92010a commit 736575d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/drivers/hitron.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
"""
1414

1515
import logging
16+
import ssl
1617
import time
1718

1819
import requests
20+
from requests.adapters import HTTPAdapter
21+
from urllib3.util.ssl_ import create_urllib3_context
1922

2023
from .base import ModemDriver
2124

@@ -32,6 +35,22 @@
3235
}
3336

3437

38+
class _LegacyTLSAdapter(HTTPAdapter):
39+
"""Allow weak certificate keys for CODA modems that use HTTPS.
40+
41+
Some CODA-56 units serve HTTPS with certificates using short keys
42+
that modern OpenSSL rejects by default.
43+
"""
44+
45+
def init_poolmanager(self, *args, **kwargs):
46+
ctx = create_urllib3_context()
47+
ctx.check_hostname = False
48+
ctx.verify_mode = ssl.CERT_NONE
49+
ctx.set_ciphers("DEFAULT:@SECLEVEL=1")
50+
kwargs["ssl_context"] = ctx
51+
super().init_poolmanager(*args, **kwargs)
52+
53+
3554
class HitronDriver(ModemDriver):
3655
"""Driver for Hitron CODA DOCSIS 3.1 cable modems.
3756
@@ -42,6 +61,8 @@ class HitronDriver(ModemDriver):
4261
def __init__(self, url: str, user: str, password: str):
4362
super().__init__(url, user, password)
4463
self._session = requests.Session()
64+
self._session.verify = False
65+
self._session.mount("https://", _LegacyTLSAdapter())
4566
self._session.timeout = 30
4667

4768
def login(self) -> None:

0 commit comments

Comments
 (0)