authority_cert_issuer和authority_cert_serial_number必须同时存在或者两者都不存在

问题描述 投票:0回答:1

我在Anaconda 2018.12中使用Python 3.7.1并尝试使用自定义证书在公司网络中生成get()请求,我有证书的.pem,我这样使用:

response = requests.get('https://www.google.com', verify='ssl/rootCA.pem')
print(response)

当我运行这个时,我收到以下错误:

File "run.py", line 29, in <module>
response = requests.get('https://www.google.com', verify='ssl/rootCA.pem')
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
conn.connect()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 355, in connect
cert = self.sock.getpeercert()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 360, in getpeercert
'subjectAltName': get_subj_alt_name(x509)
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 210, in get_subj_alt_name
ext = cert.extensions.get_extension_for_class(
File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\utils.py", line 162, in inner
result = func(instance)
File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\x509.py", line 137, in extensions
self._backend, self._x509
File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\decode_asn1.py", line 252, in parse
value = handler(backend, ext_data)
File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\decode_asn1.py", line 376, in _decode_authority_key_identifier
key_identifier, authority_cert_issuer, authority_cert_serial_number
File "C:\ProgramData\Anaconda3\lib\site-packages\cryptography\x509\extensions.py", line 152, in __init__
"authority_cert_issuer and authority_cert_serial_number "

ValueError: authority_cert_issuer and authority_cert_serial_number must both be present or both None

我的证书非常简单

-----BEGIN CERTIFICATE-----
... certificate in here ...
-----END CERTIFICATE-----

而且我之前使用过这种方法使用相同的证书(实际上是.pem),所以我不确定我必须做些什么才能导致这个问题。

python ssl python-requests anaconda python-3.7
1个回答
0
投票

我通过抛弃Anaconda解决了这个问题,只是使用Python并将REQUESTS_CA_BUNDLE路径设置为:

set REQUESTS_CA_BUNDLE=C:\Users\User\workspaces\ssl\rootCA.pem
© www.soinside.com 2019 - 2024. All rights reserved.