scrapinghub / slackbot

A chat bot for Slack (https://slack.com).
MIT License
1.26k stars 394 forks source link

TypeError: cafile, capath and cadata cannot be all omitted #133

Closed riku179 closed 5 years ago

riku179 commented 7 years ago

As below code and error, bot crash on python3.6

from slackbot.bot import Bot

def main():
    bot = Bot()
    bot.run()

if __name__ == '__main__':
    main()
% python3.6 run.py
Traceback (most recent call last):
  File "run.py", line 8, in <module>
    main()
  File "run.py", line 4, in main
    bot = Bot()
  File "/usr/lib/python3.6/site-packages/slackbot/bot.py", line 25, in __init__
    'BOT_EMOJI') else None
  File "/usr/lib/python3.6/site-packages/slackbot/slackclient.py", line 37, in __init__
    self.rtm_connect()
  File "/usr/lib/python3.6/site-packages/slackbot/slackclient.py", line 42, in rtm_connect
    self.parse_slack_login_data(reply)
  File "/usr/lib/python3.6/site-packages/slackbot/slackclient.py", line 63, in parse_slack_login_data
    self.websocket = create_connection(self.login_data['url'])
  File "/usr/lib/python3.6/site-packages/websocket/_core.py", line 487, in create_connection
    websock.connect(url, **options)
  File "/usr/lib/python3.6/site-packages/websocket/_core.py", line 211, in connect
    options.pop('socket', None))
  File "/usr/lib/python3.6/site-packages/websocket/_http.py", line 77, in connect
    sock = _ssl_socket(sock, options.sslopt, hostname)
  File "/usr/lib/python3.6/site-packages/websocket/_http.py", line 179, in _ssl_socket
    sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
  File "/usr/lib/python3.6/site-packages/websocket/_http.py", line 138, in _wrap_sni_socket
    context.load_verify_locations(cafile=sslopt.get('ca_certs', None))
TypeError: cafile, capath and cadata cannot be all omitted
remik commented 7 years ago

Please try again or check your config. Works good for me (updated ~1 week ago).

jtatum commented 7 years ago

Looks like an error in the websocket library, websocket-client/websocket-client#227. What version of websocket do you have on your system? In a python interpreter in your venv:

>>> import websocket
>>> websocket.__version__
'0.35.0'

This was fixed in 0.35, should be that ver or newer.

dylwhich commented 6 years ago

I was able to solve this issue by placing the cacert.pem file from websocket with the rest of its files (in my case, /usr/lib/python3.6/site-packages/websocket/).

Looking at the websocket source code, you should also be able to fix this by setting the WEBSOCKET_CLIENT_CA_BUNDLE environment variable to your system's CA bundle, e.g. /etc/pki/tls/certs/ca-bundle.crt (Fedora 25).