Nikita_Panyuhin
@Nikita_Panyuhin
Python, html, css, jQuery, js, php

Как устранить ошибку ssl сертификата в Python?

Подскажите, пожалуйста, в чём ошибка?

import ssl
import urllib.request
import requests

urllib.request.urlopen('https://oauth.vk.com/authorize?client_id=(Тут id приложения)&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&response_type=token')

r = requests.get('https://oauth.vk.com/authorize?client_id=(Тут id приложения&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&response_type=token')
print(r.json())


В ответ программа выдаёт:

Traceback (most recent call last):
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 814, in __init__
self.do_handshake()
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='oauth.vk.com', port=443): Max retries exceeded with url: /authorize?client_id=(Тут id приложения)&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&resp... (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Nikita2\Desktop\Проба - копия - копия.py", line 11, in
r = requests.get('https://oauth.vk.com/authorize?client_id=(Тут id приложения)&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&resp...')
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Nikita2\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='oauth.vk.com', port=443): Max retries exceeded with url: /authorize?client_id=(Тут id приложения)&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&resp... (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))
  • Вопрос задан
  • 154 просмотра
Решения вопроса 1
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через TM ID
Похожие вопросы
15 июля 2018, в 15:03
18000 руб./за проект
15 июля 2018, в 14:20
5000 руб./за проект