diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2019-10-17 14:45:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-17 14:45:24 +0300 |
commit | d0291aa7e69c2020121864229cc6f542bcbd5db9 (patch) | |
tree | cab876c130f42fdc010bd570a53db27599809454 /collectors/python.d.plugin/python_modules | |
parent | 10d08cd44af90074590f73d667acfe5ba475458c (diff) |
unbound: fix init (#7112)
* SocketService: fix error handling in connect and more debug output
* SocketService: use ssl.PROTOCOL_SSLv23 instead of ssl.PROTOCOL_TLS for py2
* unbound: conf parse fix
Diffstat (limited to 'collectors/python.d.plugin/python_modules')
-rw-r--r-- | collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py index 3b94fcdf2f..337bf57d89 100644 --- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py +++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py @@ -14,6 +14,12 @@ except ImportError: else: _TLS_SUPPORT = True +if _TLS_SUPPORT: + try: + PROTOCOL_TLS = ssl.PROTOCOL_TLS + except AttributeError: + PROTOCOL_TLS = ssl.PROTOCOL_SSLv23 + from bases.FrameworkServices.SimpleService import SimpleService @@ -80,15 +86,18 @@ class SocketService(SimpleService): if self.tls: try: self.debug('Encapsulating socket with TLS') + self.debug('Using keyfile: {0}, certfile: {1}, cert_reqs: {2}, ssl_version: {3}'.format( + self.key, self.cert, ssl.CERT_NONE, PROTOCOL_TLS + )) self._sock = ssl.wrap_socket(self._sock, keyfile=self.key, certfile=self.cert, server_side=False, cert_reqs=ssl.CERT_NONE, - ssl_version=ssl.PROTOCOL_TLS, + ssl_version=PROTOCOL_TLS, ) - except (socket.error, ssl.SSLError) as error: - self.error('failed to wrap socket : {0}'.format(error)) + except (socket.error, ssl.SSLError, IOError, OSError) as error: + self.error('failed to wrap socket : {0}'.format(repr(error))) self._disconnect() self.__socket_config = None return False @@ -167,7 +176,8 @@ class SocketService(SimpleService): if self._connect2socket(res): break - except Exception: + except Exception as error: + self.error('unhandled exception during connect : {0}'.format(repr(error))) self._sock = None self.__socket_config = None |