Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSL support #44

Merged
merged 6 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sagemcom_api"
version = "1.0.4"
version = "1.0.5beta0"
description = "Python client to interact with SagemCom F@st routers via internal API's."
authors = ["Mick Vleeshouwer <[email protected]>"]
license = "MIT"
Expand Down
7 changes: 6 additions & 1 deletion sagemcom_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(
password,
authentication_method,
session: ClientSession = None,
ssl=False,
verify_ssl=False,
):
"""
Create a SagemCom client.
Expand All @@ -65,6 +67,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 @@ -76,6 +80,7 @@ def __init__(
else ClientSession(
headers={"User-Agent": f"{DEFAULT_USER_AGENT}/{__version__}"},
timeout=ClientTimeout(DEFAULT_TIMEOUT),
ssl=verify_ssl,
)
)

Expand Down Expand Up @@ -172,7 +177,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