Skip to content

Commit 957aac4

Browse files
Merge pull request #76 from vossen-adobe/ssl_verify
Ssl verify
2 parents 480199b + 57e1643 commit 957aac4

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: python
22
python:
33
- 2.7
4-
- 3.4
54
- 3.5
65
- 3.6
6+
- 3.7
7+
- 3.8
78
install:
89
- pip install --upgrade pip setuptools wheel
910
- pip install -r requirements.txt

docs/usage-instructions-v2.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,32 @@ for group in groups:
135135
print(group)
136136
```
137137

138+
## Disabling SSL Verification
139+
140+
In environments where SSL inspection is enforced at the firewall, the UMAPI client can encounter the following error:
141+
142+
2017-07-07 09:01:37 4916 CRITICAL main - UMAPI connection to org id 'someUUIDvalue@AdobeOrg' failed: [SSL: CERTIFICATE_VERIFY_FAILED]
143+
144+
This is because the requests module is not aware of the middle-man certificate required for SSL inspection. The recommended solution to this problem is to specify a path to the certificate bundle using the REQUESTS_CA_BUNDLE environment variable (see https://helpx.adobe.com/enterprise/kb/UMAPI-UST.html for details). However, in some cases following these steps does not solve the problem. The next logical step is to disable SSL inspection on the firewall for the UMAPI traffic. If, however, this is not permitted, you may work around the issue by disabling SSL verification for user-sync.
145+
146+
Disabling the verification is unsafe, and leaves the umapi client vulnerable to middle man attacks, so it is recommended to avoid disabling it if at all possible. The umapi client only ever targets two URLs - the usermanagement endpoint and the ims endpoint - both of which are secure Adobe URL's. In addition, since this option is only recommended for use in a secure network environment, any potential risk is further mitigated.
147+
148+
To bypass the SSL verification, construct the Connection object using `ssl_verify=False` argument (set the True by default). Borrowing from the initial example,
149+
150+
```python
151+
conn = umapi_client.Connection(
152+
org_id=config["org_id"],
153+
auth_dict=config,
154+
ssl_verify=False
155+
)
156+
```
157+
158+
During the calls, you will also see a warning from requests:
159+
160+
"InsecureRequestWarning: Unverified HTTPS request is being made to host 'usermanagement-stage.adobe.io'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
161+
InsecureRequestWarning"
162+
163+
138164
# Performing Operations on Users
139165

140166
User operations in the UMAPI are performed in three steps:

umapi_client/connection.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(self,
5353
retry_max_attempts=4,
5454
retry_first_delay=15,
5555
retry_random_delay=5,
56+
ssl_verify=True,
5657
timeout_seconds=120.0,
5758
throttle_actions=10,
5859
throttle_commands=10,
@@ -121,6 +122,7 @@ def __init__(self,
121122
self.retry_max_attempts = retry_max_attempts
122123
self.retry_first_delay = retry_first_delay
123124
self.retry_random_delay = retry_random_delay
125+
self.ssl_verify = ssl_verify
124126
self.timeout = float(timeout_seconds) if timeout_seconds and float(timeout_seconds) > 0.0 else None
125127
self.throttle_actions = max(int(throttle_actions), 1)
126128
self.throttle_commands = max(int(throttle_commands), 1)
@@ -182,7 +184,8 @@ def status(self, remote=False):
182184
if remote:
183185
components = urlparse.urlparse(self.endpoint)
184186
try:
185-
result = self.session.get(components[0] + "://" + components[1] + "/status", timeout=self.timeout)
187+
result = self.session.get(components[0] + "://" + components[1] + "/status", timeout=self.timeout,
188+
verify=self.ssl_verify)
186189
except Exception as e:
187190
if self.logger: self.logger.debug("Failed to connect to server for status: %s", e)
188191
result = None
@@ -421,14 +424,17 @@ def make_call(self, path, body=None, delete=False):
421424
if body:
422425
request_body = json.dumps(body)
423426
def call():
424-
return self.session.post(self.endpoint + path, auth=self.auth, data=request_body, timeout=self.timeout)
427+
return self.session.post(self.endpoint + path, auth=self.auth, data=request_body, timeout=self.timeout,
428+
verify=self.ssl_verify)
425429
else:
426430
if not delete:
427431
def call():
428-
return self.session.get(self.endpoint + path, auth=self.auth, timeout=self.timeout)
432+
return self.session.get(self.endpoint + path, auth=self.auth, timeout=self.timeout,
433+
verify=self.ssl_verify)
429434
else:
430435
def call():
431-
return self.session.delete(self.endpoint + path, auth=self.auth, timeout=self.timeout)
436+
return self.session.delete(self.endpoint + path, auth=self.auth, timeout=self.timeout,
437+
verify=self.ssl_verify)
432438

433439
start_time = time()
434440
result = None

0 commit comments

Comments
 (0)