python-3.x - 请求 SSLError : [SSL: CERTIFICATE_VERIFY_FAILED] Windows

标签 python-3.x ssl openssl ssl-certificate anaconda

当我设置 verify = False 时,我得到了 200 响应。当我设置 verify = True 时,我收到 SSL 错误。我更新了 certifi 和 opensll,但不确定下一步该做什么。我在 Windows 上使用 Anaconda。我相信我需要从 https://api.seatgeek.com/2/events?client_id=MYCLIENTID 下载域验证证书作为 *.crt 或 *pem 文件,但不确定如何做到这一点。

Traceback (most recent call last):
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connection.py", line 326, in connect
    ssl_context=context)
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 808, in __init__
    self.do_handshake()
  File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "C:\Anaconda\envs\seatgeek\lib\ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\requests\adapters.py", line 440, in send
    timeout=timeout
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Anaconda\envs\seatgeek\lib\site-packages\urllib3\util\retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.seatgeek.com', port=443): Max retries exceeded with url: (Caused by SSLError(SSLError(1, '[SSL: CERT
IFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),))

import requests

with open("id.txt","r") as file:
    read_data = file.readlines()
    client_id_data = read_data[1]

CLIENT_ID = client_id_data

payload = {'performers[home_team].slug': 'warriors','client_id': 
CLIENT_ID}

response = requests.get('https://api.seatgeek.com/2/events', verify = True, 
params=payload)

最佳答案

您可以为链接导出证书 https://api.seatgeek.com/2/events?client_id=MYCLIENTID使用 chrome/firefox 浏览器,这是一个 wikihow 链接 https://www.wikihow.com/Export-Certificate-Public-Key-from-Chrome

关于python-3.x - 请求 SSLError : [SSL: CERTIFICATE_VERIFY_FAILED] Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48647692/

相关文章:

python - 如何在 Python 中混合使用多个可选参数?

python - 从具有子父关系的列表开始,创建一个包含子项的父项作为列表

node.js - "This Connection is Untrusted"但仅限于 firefox

python - 使用 Python RSA 将请求复制到 Chef

openssl - 没有可用的对等证书

python-3.x - 抓取时绕过 403

python-3.x - 在python pandas中基于df值比较创建派生字段

windows - cpprestsdk SSL post 不适用于 Windows7 但适用于 Windows 10

ssl - 将letsencrypt ssl添加到 Jenkins 服务器

Windows/Perl/Net::SSLeay/OpenSSL:从哪些位置加载 CA 证书?