fix handling of some TLS options in Component configs

This commit is contained in:
meejah
2017-06-08 16:43:40 -06:00
committed by Tobias Oberstein
parent e69b3146fa
commit 593ce9a70c
2 changed files with 7 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ except ImportError as e:
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

View File

@@ -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"