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

Added option to disable ssl cert verification #142

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions webexteamssdk/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
redirect_uri=None,
proxies=None,
be_geo_id=None,
caller=None):
caller=None,
disable_ssl_verify=False):
"""Create a new WebexTeamsAPI object.

An access token must be used when interacting with the Webex Teams API.
Expand Down Expand Up @@ -122,6 +123,9 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
caller(basestring): Optional identifier for API usage tracking.
Defaults to checking for a WEBEX_PYTHON_SDK_CALLER environment
variable.
disable_ssl_verify(bool): Optional boolean flag to disable ssl
verification. Defaults to False. If set to True, the requests
session won't verify ssl certs anymore.

Returns:
WebexTeamsAPI: A new WebexTeamsAPI object.
Expand All @@ -143,6 +147,7 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
check_type(proxies, dict, optional=True)
check_type(be_geo_id, basestring, optional=True)
check_type(caller, basestring, optional=True)
check_type(disable_ssl_verify, bool, optional=True)

access_token = access_token or WEBEX_TEAMS_ACCESS_TOKEN

Expand Down Expand Up @@ -186,7 +191,8 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
wait_on_rate_limit=wait_on_rate_limit,
proxies=proxies,
be_geo_id=be_geo_id,
caller=caller
caller=caller,
disable_ssl_verify=disable_ssl_verify
)

# API wrappers
Expand Down
12 changes: 11 additions & 1 deletion webexteamssdk/restsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def __init__(self, access_token, base_url,
wait_on_rate_limit=DEFAULT_WAIT_ON_RATE_LIMIT,
proxies=None,
be_geo_id=None,
caller=None):
caller=None,
disable_ssl_verify=False):
"""Initialize a new RestSession object.

Args:
Expand All @@ -198,6 +199,9 @@ def __init__(self, access_token, base_url,
caller(basestring): Optional identifier for API usage tracking.
Defaults to checking for a WEBEX_PYTHON_SDK_CALLER environment
variable.
disable_ssl_verify(bool): Optional boolean flag to disable ssl
verification. Defaults to False. If set to true, the requests
session won't verify ssl certs anymore.

Raises:
TypeError: If the parameter types are incorrect.
Expand All @@ -208,6 +212,7 @@ def __init__(self, access_token, base_url,
check_type(single_request_timeout, int, optional=True)
check_type(wait_on_rate_limit, bool)
check_type(proxies, dict, optional=True)
check_type(disable_ssl_verify, bool, optional=True)

super(RestSession, self).__init__()

Expand All @@ -220,6 +225,11 @@ def __init__(self, access_token, base_url,
# Initialize a new session
self._req_session = requests.session()

# Disable ssl cert verification if chosen by user
if disable_ssl_verify:
self._req_session.verify = False


if proxies is not None:
self._req_session.proxies.update(proxies)

Expand Down