Skip to content

Commit

Permalink
Add possibility in example to ignore cert errors and fix the verify_s…
Browse files Browse the repository at this point in the history
…sl assignment in code (#353)

This addresses #298, adding it explicitly to the example and making it
easier for new users to toggle it.
Additionally, the TCPConnector assignment was broken, and this was fixed
too.

---------

Co-authored-by: Mick <[email protected]>
  • Loading branch information
bunnis and iMicknl authored Oct 15, 2024
1 parent c62f9a3 commit 429855c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ HOST = ""
USERNAME = ""
PASSWORD = ""
ENCRYPTION_METHOD = EncryptionMethod.SHA512 # or EncryptionMethod.MD5
VALIDATE_SSL_CERT = True

async def main() -> None:
async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD) as client:
async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD, verify_ssl=VALIDATE_SSL_CERT) as client:
try:
await client.login()
except Exception as exception: # pylint: disable=broad-except
Expand Down
4 changes: 3 additions & 1 deletion sagemcom_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def __init__(
else ClientSession(
headers={"User-Agent": f"{DEFAULT_USER_AGENT}"},
timeout=ClientTimeout(DEFAULT_TIMEOUT),
connector=TCPConnector(verify_ssl=verify_ssl if verify_ssl else True),
connector=TCPConnector(
verify_ssl=verify_ssl if verify_ssl is not None else True
),
)
)

Expand Down

0 comments on commit 429855c

Please sign in to comment.