Skip to content

Commit dd94c8d

Browse files
authored
Add SSL support (#44)
* Add HTTPS support * Bump to 1.0.5beta0 * Bugfix * Revert change
1 parent e38c601 commit dd94c8d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sagemcom_api/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import urllib.parse
1212

1313
from aiohttp import ClientSession, ClientTimeout
14+
from aiohttp.connector import TCPConnector
1415
import humps
1516

1617
from . import __version__
@@ -52,6 +53,8 @@ def __init__(
5253
password,
5354
authentication_method,
5455
session: ClientSession = None,
56+
ssl=False,
57+
verify_ssl=True,
5558
):
5659
"""
5760
Create a SagemCom client.
@@ -67,6 +70,8 @@ def __init__(
6770
self.authentication_method = authentication_method
6871
self._password_hash = self.__generate_hash(password)
6972

73+
self.protocol = "https" if ssl else "http"
74+
7075
self._current_nonce = None
7176
self._server_nonce = ""
7277
self._session_id = 0
@@ -78,6 +83,7 @@ def __init__(
7883
else ClientSession(
7984
headers={"User-Agent": f"{DEFAULT_USER_AGENT}/{__version__}"},
8085
timeout=ClientTimeout(DEFAULT_TIMEOUT),
86+
connector=TCPConnector(ssl=verify_ssl),
8187
)
8288
)
8389

@@ -174,7 +180,7 @@ async def __api_request_async(self, actions, priority=False):
174180
self.__generate_nonce()
175181
self.__generate_auth_key()
176182

177-
api_host = f"http://{self.host}{API_ENDPOINT}"
183+
api_host = f"{self.protocol}://{self.host}{API_ENDPOINT}"
178184

179185
payload = {
180186
"request": {

0 commit comments

Comments
 (0)