From 93d8b79900435e2f3b1755963e4a465cb6d4cdbf Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 3 Nov 2015 09:13:44 -0500 Subject: [PATCH] Don't warn on configured insecure certs If we have to connect to bogus certs and we know this and we've configured 'verfiy=False' meaning that we've explicitly indicated that we want to turn off cert verification, then spamming our logs with warnings that the certs are invalid is a bit lame. We know. We're not happy about it - but at least one of our providers has bad certs. We wish we had the power to change it, but we don't. We already feel bad. STOP YELLING AT US. Change-Id: I08d816bcc1685fc9ed3bfcf2e3e8300859059903 --- shade/openstackcloud.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index d1177e4c8..d79e7e110 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -18,6 +18,7 @@ import os_client_config import os_client_config.defaults import threading import time +import warnings from dogpile import cache @@ -48,6 +49,14 @@ from shade import task_manager from shade import _tasks from shade import _utils +# Importing these for later but not disabling for now +try: + from requests.packages.urllib3.exceptions import InsecureRequestWarning +except ImportError: + try: + from urllib3.exceptions import InsecureRequestWarning + except ImportError: + InsecureRequestWarning = None OBJECT_MD5_KEY = 'x-object-meta-x-shade-md5' OBJECT_SHA256_KEY = 'x-object-meta-x-shade-sha256' @@ -157,6 +166,13 @@ class OpenStackCloud(object): name=self.name, client=self) (self.verify, self.cert) = cloud_config.get_requests_verify_args() + # Turn off urllib3 warnings about insecure certs if we have + # explicitly configured requests to tell it we do not want + # cert verification + if not self.verify: + self.log.debug( + "Turning off Insecure SSL warnings since verify=False") + warnings.filterwarnings('ignore', category=InsecureRequestWarning) self._servers = [] self._servers_time = 0