Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix handling of some TLS options in Component configs #848

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion autobahn/twisted/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
if 'OpenSSL' not in str(e):
raise

import six
import txaio

from autobahn.twisted.websocket import WampWebSocketClientFactory
Expand Down Expand Up @@ -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'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, I think it would be much better not to coerce the type, but to raise if the user does not provide a string. no type coercions at all (we had that, and it was painful to remove again).

port = int(endpoint_config['port'])
timeout = int(endpoint_config.get('timeout', 10)) # in seconds
tls = endpoint_config.get('tls', None)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion autobahn/wamp/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down