Add SubjectAltNameWarning and a helper function
shade hits the SubjectAltName problem when talking to Rackspace. Also, one of the things you want to do is turn off the warnings - so add a function for that. Change-Id: I3a55c66e5a4033a47a9d8704dd30709a5c53edc9
This commit is contained in:
parent
82fb34c4e9
commit
448d469780
|
@ -12,6 +12,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import warnings
|
||||
|
||||
try:
|
||||
from requests.packages.urllib3.exceptions import InsecurePlatformWarning
|
||||
except ImportError:
|
||||
|
@ -27,3 +29,20 @@ except ImportError:
|
|||
from urllib3.exceptions import InsecureRequestWarning
|
||||
except ImportError:
|
||||
InsecureRequestWarning = None
|
||||
|
||||
try:
|
||||
from requests.packages.urllib3.exceptions import SubjectAltNameWarning
|
||||
except ImportError:
|
||||
try:
|
||||
from urllib3.exceptions import SubjectAltNameWarning
|
||||
except ImportError:
|
||||
SubjectAltNameWarning = None
|
||||
|
||||
|
||||
def squelch_warnings(insecure_requests=True):
|
||||
if SubjectAltNameWarning:
|
||||
warnings.filterwarnings('ignore', category=SubjectAltNameWarning)
|
||||
if InsecurePlatformWarning:
|
||||
warnings.filterwarnings('ignore', category=InsecurePlatformWarning)
|
||||
if insecure_requests and InsecureRequestWarning):
|
||||
warnings.filterwarnings('ignore', category=InsecureRequestWarning)
|
||||
|
|
Loading…
Reference in New Issue