aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2016-03-11 15:36:58 +0000
committerRyan Huber <rhuber@gmail.com>2016-03-11 15:36:58 +0000
commitd02a8d2d16cb8f4378c63259b7575945ad71aed9 (patch)
tree52c21e19ef5d79aee4e816d188998690198a7cb4
parentae29435767678193c506ef35933d48e6bc856420 (diff)
parent5ffb244926c709389cf37aa87d1bbfe4f665ffb1 (diff)
downloadwee-slack-d02a8d2d16cb8f4378c63259b7575945ad71aed9.tar.gz
Merge pull request #171 from rawdigits/default_tls_options
Pass system default ssl options to websocket.create_connection
-rw-r--r--wee_slack.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index b289ac3..cc7c7cd 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.
@@ -263,7 +271,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