diff options
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 |