From: Thierry Parmentelat Date: Wed, 16 Dec 2015 08:26:59 +0000 (+0100) Subject: better patch for unverified context X-Git-Tag: bootmanager-5.3-4~1 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=inline;h=1ab7cb7d702a54d90ebcefb6f7a872fd5d62b458;p=bootmanager.git better patch for unverified context --- diff --git a/source/RunlevelAgent.py b/source/RunlevelAgent.py index 8dd3474..0d514c3 100755 --- a/source/RunlevelAgent.py +++ b/source/RunlevelAgent.py @@ -77,11 +77,10 @@ class PLC: self.url = url # Using a self signed certificate # https://www.python.org/dev/peps/pep-0476/ - if hasattr(ssl, '_create_unverified_context'): - self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True, - context=ssl._create_unverified_context()) - else : - self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True) + try: turn_off_server_verify = { 'context' : ssl._create_unverified_context() } + except: turn_off_server_verify = {} + self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True, + **turn_off_server_verify) def __getattr__(self, name): method = getattr(self.api, name)