I am following this guide here to try and build a simple bot: https://www.fullstackpython.com/blog/build-first-slack-bot-python.html
I have made it to the point where you actually run the code "python starterbot.py" and when I run the code I get a SSL certificate verify failed error. I will post the whole error messages at the bottom. I am not sure if it is an SSL error, or if it is because of the proxy I am behind since I am running it from my office computer.
I am running this on windows through the command prompt
Below is the messages I get when trying to run the code
python starterbot.py
Traceback (most recent call last):
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3connectionpool.py", line 595, in urlopen
self._prepare_proxy(conn)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3connectionpool.py", line 816, in _prepare_proxy
conn.connect()
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3connection.py", line 326, in connect
ssl_context=context)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3utilssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libssl.py", line 814, in __init__
self.do_handshake()
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestsadapters.py", line 440, in send
timeout=timeout
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesurllib3utilretry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='slack.com', port=443): Max retries exceeded with url: /api/rtm.connect (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesslackclientclient.py", line 52, in rtm_connect
self.server.rtm_connect(use_rtm_start=with_team_state, *kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesslackclientserver.py", line 131, in rtm_connect
reply = self.api_requester.do(self.token, connect_method, timeout=timeout, post_data=kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesslackclientslackrequest.py", line 104, in do
proxies=self.proxies
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestsapi.py", line 112, in post
return request('post', url, data=data, json=json, *kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestsapi.py", line 58, in request
return session.request(method=method, url=url, *kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestssessions.py", line 508, in request
resp = self.send(prep, *send_kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestssessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:Usersn0342338AppDataLocalProgramsPythonPython36libsite-packagesrequestsadapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='slack.com', port=443): Max retries exceeded with url: /api/rtm.connect (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
slackclient version:
python version:3.6.5
OS version(s):Windows 10
1.
2.
3.
What you expected to happen
What actually happened
Logs, screenshots, screencast, sample project, funny gif, etc.
What was your solution? @LMPK
@DanielLuu
I had to go into the slackrequest.py file and under the 'return requests.post()' add in 'verify=False'. So it looks like this:
return requests.post(
url,
headers=headers,
data=post_data,
verify=False,
files=files,
timeout=timeout,
proxies=proxiess
#proxies=self.proxies
)
This is a workaround that I found, so it is a bit janky, but it fixed that error for me.
I also had to specify the proxies that are used at my company, and make sure these are referenced in the code above. By doing this:
proxiess={
'http': 'http://user:pass@proxy:port',
'https': 'http://user:pass@proxy:port',
}
The above two fixed that problem, but I encountered an Slack Login Error after that which I am still trying to figure out.
Hope this helps.
You can add ssl=True and works like a charm!
client = slack.WebClient(token='my-secret-token', ssl=True)
Most helpful comment
@DanielLuu
I had to go into the slackrequest.py file and under the 'return requests.post()' add in 'verify=False'. So it looks like this:
This is a workaround that I found, so it is a bit janky, but it fixed that error for me.
I also had to specify the proxies that are used at my company, and make sure these are referenced in the code above. By doing this:
The above two fixed that problem, but I encountered an Slack Login Error after that which I am still trying to figure out.
Hope this helps.