Skip to content

Commit 0e4e9ad

Browse files
committed
Merge pull request #13 from WLPhoenix/master
urllib3 insecure warnings
2 parents d377a24 + 668c05a commit 0e4e9ad

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-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: 19 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

@@ -25,6 +27,11 @@
2527

2628
logger = logging.getLogger(__name__)
2729

30+
HTTP_INSECURE_MESSAGE = "\n".join([
31+
"You have chosen not to verify ssl connections.",
32+
"This is insecure, but it's your choice.",
33+
"This has been your single warning."])
34+
2835

2936
def use_admin_auth(func):
3037

@@ -96,7 +103,7 @@ class HttpMixin(object):
96103

97104
HEADERS = {
98105
'json': {"content-type": "application/json"},
99-
#'xml': {"content-type": "application/xml"}
106+
'xml': {"content-type": "application/xml"}
100107
}
101108

102109
def __init__(self, auth=None, verify=True):
@@ -106,6 +113,17 @@ def __init__(self, auth=None, verify=True):
106113
}
107114
self._http_log = logging.getLogger(__name__)
108115

116+
if not verify:
117+
if self._http_log.handlers:
118+
self._http_log.warn(HTTP_INSECURE_MESSAGE)
119+
else:
120+
print(HTTP_INSECURE_MESSAGE)
121+
122+
from requests.packages.urllib3 import disable_warnings
123+
disable_warnings()
124+
125+
126+
109127
def _request(self, verb, url, quiet=False,
110128
none_on_404=False, jsonify=False, raise_for_status=True,
111129
*args, **kwargs):

0 commit comments

Comments
 (0)