と私はそれに非常に同様の問題を抱えていない私はurllib3ライブラリでのpython 3.4を使用していますhereSSL証明書は明らかに検証するSSLクライアントで動作しますが、urllib3
を議論しました。
私は以下のコードをテストする場合、私が取得:
Traceback (most recent call last):
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
self._validate_conn(conn)
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
conn.connect()
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/util/ssl_.py", line 324, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.4/ssl.py", line 364, in wrap_socket
_context=self)
File "/usr/lib/python3.4/ssl.py", line 578, in __init__
self.do_handshake()
File "/usr/lib/python3.4/ssl.py", line 805, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 630, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/julimatt/workspace2/zibawa/stack_configs/tests.py", line 44, in test_bind_grafana
result=getFromGrafanaApi(apiurl, data,'GET')
File "/home/julimatt/workspace2/zibawa/stack_configs/models.py", line 317, in getFromGrafanaApi
verify=ca_certs,
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/home/julimatt/zibawa3/zib3/lib/python3.4/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
私のコードは次のとおりです。
from requests import Request, Session
ca_certs='/path/to/letsencypt/fullchain.pem'
url= 'https://myserver.com:3000/api/org'
username= settings.DASHBOARD['user']
password= settings.DASHBOARD['password']
headers = {'Accept': 'application/json',
'Content-Type' : 'application/json',}
s = Session()
req = Request('GET', url, data=data, headers=headers, auth=(username,password))
prepped = s.prepare_request(req)
resp = s.send(prepped,
verify=ca_certs,
)
print(resp.status_code)
return resp
私はリクエストに「= Falseの検証」と自分のコードをテストする場合、それは動作しますそれは明らかに安全な解決策ではありません。
私が使用して、同じマシン上の端末からの私のSSL接続をテストしてみました:その後、私は成功し握手を取得
openssl s_client -connect myserver.com:3000 -CAfile /path/to/letsencypt/fullchain.pem
を。
なぜこのエラーが発生するのか理解できません。
お手数ですがお寄せいただきありがとうございます。