Huawei: disable certificate verification

Globally disable verification by monkeypatching the ssl
module in version of Python that enable certificate verification
by default for stdlib http clients.

Change-Id: If672933e581f06ffcd4c8d64921d061f42de23dc
Closes-Bug: #1672288
This commit is contained in:
liucheng 2017-03-21 14:25:00 +08:00
parent a55a6b5c71
commit 9ed6fac24c
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import json
import re
import six
import socket
import ssl
import time
from oslo_log import log as logging
@ -72,6 +73,14 @@ class RestClient(object):
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)
res_json = None
try:
create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = create_unverified_https_context
try:
socket.setdefaulttimeout(calltimeout)

View File

@ -0,0 +1,3 @@
---
fixes:
SSL certificate validation is now disabled for the Huawei driver.