Skip to content

Commit 832d9aa

Browse files
committed
Added handler for urllib3 warning insecure warning messages, defaulted client to verify=True
1 parent d377a24 commit 832d9aa

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

stackdio/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class StackdIO(BlueprintMixin, FormulaMixin, ProfileMixin,
3939

4040
def __init__(self, protocol="https", host="localhost", port=443,
4141
base_url=None, auth=None, auth_admin=None,
42-
verify=False):
42+
verify=True):
4343
"""auth_admin is optional, only needed for creating provider, profile,
4444
and base security groups"""
4545

stackdio/client/http.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# limitations under the License.
1616
#
1717

18+
from __future__ import print_function
19+
1820
import logging
1921
import requests
2022

@@ -96,7 +98,7 @@ class HttpMixin(object):
9698

9799
HEADERS = {
98100
'json': {"content-type": "application/json"},
99-
#'xml': {"content-type": "application/xml"}
101+
'xml': {"content-type": "application/xml"}
100102
}
101103

102104
def __init__(self, auth=None, verify=True):
@@ -106,6 +108,21 @@ def __init__(self, auth=None, verify=True):
106108
}
107109
self._http_log = logging.getLogger(__name__)
108110

111+
if not verify:
112+
if self._http_log.handlers:
113+
self._http_log.warn("You have chosen not to verify ssl connections.")
114+
self._http_log.warn("This is insecure, but it's your choice.")
115+
self._http_log.warn("This has been your single warning.")
116+
else:
117+
print("You have chosen not to verify ssl connections.")
118+
print("This is insecure, but it's your choice.")
119+
print("This has been your single warning.")
120+
121+
from requests.packages.urllib3 import disable_warnings
122+
disable_warnings()
123+
124+
125+
109126
def _request(self, verb, url, quiet=False,
110127
none_on_404=False, jsonify=False, raise_for_status=True,
111128
*args, **kwargs):

0 commit comments

Comments
 (0)