fix handling of some TLS options in Component configs
This commit is contained in:
@@ -45,6 +45,7 @@ except ImportError as e:
|
|||||||
if 'OpenSSL' not in str(e):
|
if 'OpenSSL' not in str(e):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
import six
|
||||||
import txaio
|
import txaio
|
||||||
|
|
||||||
from autobahn.twisted.websocket import WampWebSocketClientFactory
|
from autobahn.twisted.websocket import WampWebSocketClientFactory
|
||||||
@@ -193,7 +194,7 @@ def _create_transport_endpoint(reactor, endpoint_config):
|
|||||||
if endpoint_config['type'] == 'tcp':
|
if endpoint_config['type'] == 'tcp':
|
||||||
|
|
||||||
version = int(endpoint_config.get('version', 4))
|
version = int(endpoint_config.get('version', 4))
|
||||||
host = str(endpoint_config['host'])
|
host = six.text_type(endpoint_config['host'])
|
||||||
port = int(endpoint_config['port'])
|
port = int(endpoint_config['port'])
|
||||||
timeout = int(endpoint_config.get('timeout', 10)) # in seconds
|
timeout = int(endpoint_config.get('timeout', 10)) # in seconds
|
||||||
tls = endpoint_config.get('tls', None)
|
tls = endpoint_config.get('tls', None)
|
||||||
@@ -208,6 +209,10 @@ def _create_transport_endpoint(reactor, endpoint_config):
|
|||||||
# eg created from twisted.internet.ssl.optionsForClientTLS()
|
# eg created from twisted.internet.ssl.optionsForClientTLS()
|
||||||
context = IOpenSSLClientConnectionCreator(tls)
|
context = IOpenSSLClientConnectionCreator(tls)
|
||||||
|
|
||||||
|
elif isinstance(tls, dict):
|
||||||
|
hostname = tls.get('hostname', host)
|
||||||
|
context = optionsForClientTLS(hostname)
|
||||||
|
|
||||||
elif isinstance(tls, CertificateOptions):
|
elif isinstance(tls, CertificateOptions):
|
||||||
context = tls
|
context = tls
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ def _create_transport(index, transport, check_native_endpoint=None):
|
|||||||
'type': 'tcp',
|
'type': 'tcp',
|
||||||
'host': host,
|
'host': host,
|
||||||
'port': port,
|
'port': port,
|
||||||
'tls': False if not is_secure else dict(hostname=host),
|
'tls': is_secure,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
# note: we're avoiding mutating the incoming "configuration"
|
# note: we're avoiding mutating the incoming "configuration"
|
||||||
|
|||||||
Reference in New Issue
Block a user