diff options
author | Tollef Fog Heen <tfheen@err.no> | 2016-03-05 11:58:50 +0100 |
---|---|---|
committer | Tollef Fog Heen <tfheen@err.no> | 2016-03-05 12:15:57 +0100 |
commit | 5ffb244926c709389cf37aa87d1bbfe4f665ffb1 (patch) | |
tree | d4163c549eb147dbc122f8e30e38d1c860f94dc3 /wee_slack.py | |
parent | efb41803ed9293f0724da2c93898abd481a3a908 (diff) | |
download | wee-slack-5ffb244926c709389cf37aa87d1bbfe4f665ffb1.tar.gz |
Pass system default ssl options to websocket.create_connection
Thanks to @daurnimator and @trygveaa for patches this is built on.
Fixes: #165
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py index 6172636..48ea76d 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -13,6 +13,8 @@ import HTMLParser import sys import traceback import collections +import ssl + from websocket import create_connection,WebSocketConnectionClosedException # hack to make tests possible.. better way? @@ -58,6 +60,12 @@ SLACK_API_TRANSLATOR = { NICK_GROUP_HERE = "0|Here" NICK_GROUP_AWAY = "1|Away" +sslopt_ca_certs = {} +if hasattr(ssl, "get_default_verify_paths") and callable(ssl.get_default_verify_paths): + ssl_defaults = ssl.get_default_verify_paths() + if ssl_defaults.cafile is not None: + sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile} + def dbg(message, fout=False, main_buffer=False): """ send debug output to the slack-debug buffer and optionally write to a file. @@ -261,7 +269,7 @@ class SlackServer(object): def create_slack_websocket(self, data): web_socket_url = data['url'] try: - self.ws = create_connection(web_socket_url) + self.ws = create_connection(web_socket_url, sslopt=sslopt_ca_certs) self.ws_hook = w.hook_fd(self.ws.sock._sock.fileno(), 1, 0, 0, "slack_websocket_cb", self.identifier) self.ws.sock.setblocking(0) return True |