Skip to content

Commit b5d914b

Browse files
committed
Disable SSL certificate validation if ssl module not available.
1 parent fd8a0ba commit b5d914b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

shotgun_api3/shotgun.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
import lib.simplejson as json
6767
sys.path.pop()
6868

69+
try:
70+
import ssl
71+
NO_SSL_VALIDATION = False
72+
except ImportError:
73+
LOG.debug("ssl not found, disabling certificate validation")
74+
NO_SSL_VALIDATION = True
75+
6976
# ----------------------------------------------------------------------------
7077
# Version
7178
__version__ = "3.0.8"
@@ -183,6 +190,7 @@ def __init__(self):
183190
self.proxy_pass = None
184191
self.session_token = None
185192
self.authorization = None
193+
self.no_ssl_validation = False
186194

187195
class Shotgun(object):
188196
"""Shotgun Client Connection"""
@@ -229,6 +237,7 @@ def __init__(self,
229237
self.config.api_key = api_key
230238
self.config.script_name = script_name
231239
self.config.convert_datetimes_to_utc = convert_datetimes_to_utc
240+
self.config.no_ssl_validation = NO_SSL_VALIDATION
232241
self._connection = None
233242

234243
self.base_url = (base_url or "").lower()
@@ -1235,9 +1244,10 @@ def _get_connection(self):
12351244
self.config.proxy_port, proxy_user=self.config.proxy_user,
12361245
proxy_pass=self.config.proxy_pass)
12371246
self._connection = Http(timeout=self.config.timeout_secs,
1238-
proxy_info=pi)
1247+
proxy_info=pi, disable_ssl_certificate_validation=self.config.no_ssl_validation)
12391248
else:
1240-
self._connection = Http(timeout=self.config.timeout_secs)
1249+
self._connection = Http(timeout=self.config.timeout_secs,
1250+
disable_ssl_certificate_validation=self.config.no_ssl_validation)
12411251

12421252
return self._connection
12431253

0 commit comments

Comments
 (0)