Добрый день.
Использую dialogflow.com для ИИ, на одной машине все хорошо запускается, но на моем компьютере выдает ошибку SSL сертификата, хотя все идентично. Как вылечить?
Код фуункции:
def SmartAnswer(message): #Умные ответы
request = apiai.ApiAI('TOKEN').text_request() # Токен API к Dialogflow
request.lang = 'ru' # На каком языке будет послан запрос
request.session_id = 'Hxfhcf_bot' # ID Сессии диалога (нужно, чтобы потом учить бота)
request.query = message.text # Посылаем запрос к ИИ с сообщением от юзера
responseJson = json.loads(request.getresponse().read().decode('utf-8'))
response = responseJson['result']['fulfillment']['speech'] # Разбираем JSON и вытаскиваем ответ
bot.send_message(message.chat.id, response)
Код ошибки:
2019-12-11 16:06:55,607 (util.py:65 WorkerThread2) ERROR - TeleBot: "SSLCertVerificationError occurred, args=(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "/Users/danilavoronov/Documents/DAV'dev/davinfobot/main.py", line 58, in SmartAnswer
responseJson = json.loads(request.getresponse().read().decode('utf-8'))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/apiai/requests/request.py", line 128, in getresponse
self._connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/apiai/requests/request.py", line 82, in _connect
self._connection.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
"
Traceback (most recent call last):
File "/Users/danilavoronov/Documents/DAV'dev/davinfobot/main.py", line 84, in <module>
bot.polling() #Эта команда нужна для того, что бы бот не выключался и ожидал команды
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telebot/__init__.py", line 389, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telebot/__init__.py", line 413, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telebot/util.py", line 108, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/six.py", line 696, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "/Users/danilavoronov/Documents/DAV'dev/davinfobot/main.py", line 58, in SmartAnswer
responseJson = json.loads(request.getresponse().read().decode('utf-8'))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/apiai/requests/request.py", line 128, in getresponse
self._connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/apiai/requests/request.py", line 82, in _connect
self._connection.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)