Created
August 13, 2016 06:12
-
-
Save josefdlange/216ae1c59301fab5a54c1251a73c2396 to your computer and use it in GitHub Desktop.
Swizzle the web socket client inside of the slack client library to find its own damn Root CA file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from slackclient import SlackClient as _SlackClient | |
| class SlackClient(_SlackClient): | |
| # I'm not sure if it's my local environment, but the Slack Client | |
| # swallows an error where the websocket client beneath can't find | |
| # the root CA file. | |
| def __init__(self, *args, **kwargs): | |
| super(SlackClient, self).__init__(*args, **kwargs) | |
| def patched_connect_slack_websocket(self, ws_url): | |
| try: | |
| import websocket | |
| import ssl | |
| sslopt_ca_certs = {} | |
| ssl_defaults = ssl.get_default_verify_paths() | |
| if ssl_defaults is not None: | |
| sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile} | |
| self.websocket = websocket.create_connection(ws_url, sslopt=sslopt_ca_certs) | |
| except Exception as e: | |
| print e | |
| print 'Failed WebSocket Connection.' | |
| self.server.__class__.connect_slack_websocket = patched_connect_slack_websocket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment