diff --git a/python/ovs/poller.py b/python/ovs/poller.py index 157719c3a48..0723ed1f6a9 100644 --- a/python/ovs/poller.py +++ b/python/ovs/poller.py @@ -17,6 +17,7 @@ import select import socket +import ssl import sys import ovs.timeval @@ -25,10 +26,6 @@ if sys.platform == "win32": import ovs.winutils as winutils -try: - import ssl -except ImportError: - ssl = None try: from eventlet import patcher as eventlet_patcher diff --git a/python/ovs/socket_util.py b/python/ovs/socket_util.py index 651012bf061..5f2201bbb51 100644 --- a/python/ovs/socket_util.py +++ b/python/ovs/socket_util.py @@ -17,6 +17,7 @@ import os.path import random import socket +import ssl import sys import ovs.fatal_signal @@ -178,7 +179,11 @@ def check_connection_completion(sock): if revents & ovs.poller.POLLERR or revents & ovs.poller.POLLHUP: try: # The following should raise an exception. - sock.send("\0".encode(), socket.MSG_DONTWAIT) + if isinstance(sock, ssl.SSLSocket): + # a SSL wrapped socket does not allow non-zero optional flag + sock.send("\0".encode()) + else: + sock.send("\0".encode(), socket.MSG_DONTWAIT) # (Here's where we end up if it didn't.) # XXX rate-limit diff --git a/python/ovs/stream.py b/python/ovs/stream.py index ac5b0fd0c64..14a3c4946fe 100644 --- a/python/ovs/stream.py +++ b/python/ovs/stream.py @@ -15,16 +15,13 @@ import errno import os import socket +import ssl import sys import ovs.poller import ovs.socket_util import ovs.vlog -try: - import ssl -except ImportError: - ssl = None if sys.platform == 'win32': import ovs.winutils as winutils @@ -860,6 +857,4 @@ def close(self): return super(SSLStream, self).close() -if ssl: - # Register SSL only if the OpenSSL module is available - Stream.register_method("ssl", SSLStream) +Stream.register_method("ssl", SSLStream)