Skip to content

Commit

Permalink
Add SSL support (#44)
Browse files Browse the repository at this point in the history
* Add HTTPS support

* Bump to 1.0.5beta0

* Bugfix

* Revert change
  • Loading branch information
iMicknl authored May 2, 2021
1 parent e38c601 commit dd94c8d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sagemcom_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import urllib.parse

from aiohttp import ClientSession, ClientTimeout
from aiohttp.connector import TCPConnector
import humps

from . import __version__
Expand Down Expand Up @@ -52,6 +53,8 @@ def __init__(
password,
authentication_method,
session: ClientSession = None,
ssl=False,
verify_ssl=True,
):
"""
Create a SagemCom client.
Expand All @@ -67,6 +70,8 @@ def __init__(
self.authentication_method = authentication_method
self._password_hash = self.__generate_hash(password)

self.protocol = "https" if ssl else "http"

self._current_nonce = None
self._server_nonce = ""
self._session_id = 0
Expand All @@ -78,6 +83,7 @@ def __init__(
else ClientSession(
headers={"User-Agent": f"{DEFAULT_USER_AGENT}/{__version__}"},
timeout=ClientTimeout(DEFAULT_TIMEOUT),
connector=TCPConnector(ssl=verify_ssl),
)
)

Expand Down Expand Up @@ -174,7 +180,7 @@ async def __api_request_async(self, actions, priority=False):
self.__generate_nonce()
self.__generate_auth_key()

api_host = f"http://{self.host}{API_ENDPOINT}"
api_host = f"{self.protocol}://{self.host}{API_ENDPOINT}"

payload = {
"request": {
Expand Down

0 comments on commit dd94c8d

Please sign in to comment.