diff --git a/autobahn/twisted/component.py b/autobahn/twisted/component.py index c8e451456..27128648e 100644 --- a/autobahn/twisted/component.py +++ b/autobahn/twisted/component.py @@ -45,6 +45,7 @@ if 'OpenSSL' not in str(e): raise +import six import txaio from autobahn.twisted.websocket import WampWebSocketClientFactory @@ -193,7 +194,7 @@ def _create_transport_endpoint(reactor, endpoint_config): if endpoint_config['type'] == 'tcp': version = int(endpoint_config.get('version', 4)) - host = str(endpoint_config['host']) + host = six.text_type(endpoint_config['host']) port = int(endpoint_config['port']) timeout = int(endpoint_config.get('timeout', 10)) # in seconds tls = endpoint_config.get('tls', None) @@ -208,6 +209,10 @@ def _create_transport_endpoint(reactor, endpoint_config): # eg created from twisted.internet.ssl.optionsForClientTLS() context = IOpenSSLClientConnectionCreator(tls) + elif isinstance(tls, dict): + hostname = tls.get('hostname', host) + context = optionsForClientTLS(hostname) + elif isinstance(tls, CertificateOptions): context = tls diff --git a/autobahn/wamp/component.py b/autobahn/wamp/component.py index c6fd97c95..188cea08f 100644 --- a/autobahn/wamp/component.py +++ b/autobahn/wamp/component.py @@ -151,7 +151,7 @@ def _create_transport(index, transport, check_native_endpoint=None): 'type': 'tcp', 'host': host, 'port': port, - 'tls': False if not is_secure else dict(hostname=host), + 'tls': is_secure, } else: # note: we're avoiding mutating the incoming "configuration"