从用 ccxt 时遇到的 SSL 证书问题,参照 github 上更新了证书,创建并复制到相应路径还是没法解决,之后不记得怎么折腾了(删除再创建之类反复试验...)再请求 https 的网页又报 OSError 了

2021-07-29 02:52:26 +08:00
 yellowtail

环境 win10 python3.8(anaconda) idle jupyternotebook 网络环境开了 vpn (不然连不上交易所,考虑稳定性应该是不能在本机上用实盘了,能用其他的解决办法比如改 hosts 吗)

参照 github 上的 SSL 问题解决办法

报错内容

SSLError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/exchangeInfo (Caused by SSLError(SSLCertVerificationError("hostname 'api.binance.com' doesn't match either of '.facebook.com', '.facebook.net', '.fbcdn.net', '.fbsbx.com', '.m.facebook.com', '.messenger.com', '.xx.fbcdn.net', '.xy.fbcdn.net', '*.xz.fbcdn.net', 'facebook.com', 'messenger.com'"))) 和 ConnectionError: ('Connection aborted.', OSError(0, 'Error'))

因为之前创建删除时反复提及是否确认,所以想到在 C 盘的 system32 里头可能涉及读写权限问题,试着用 pandas 读 xlsx 文件发现没问题(只会用 pandas 读...)

按照 github 的解决办法 python -c "import ssl; print(ssl.get_default_verify_paths())输出了两个地址

DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='C:\Windows\System32\OpenSSL\SSL/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='C:\Windows\System32\OpenSSL\SSL/certs')

但是 system32 里没有 openssl 文件,而且 certifi 里 pem 文件和的 openssl_cafile 名字不一样,一个是 cacert 一个是 cert,所以我在 systems32 里的创建了两个地址( C:\Windows\System32\OpenSSL\SSL 和 C:\Windows\System32\OpenSSL\SSL/certs )然后放了两个同样只是名字不同的文件(顺便问下,上路路径为啥不能都用反斜杠和正斜杠..) 之前也试过在 ccxt 去掉 verify,记得也失败了... 还是不能用,折腾了半夜熬不住了

补充:都是用 request 试的,因为 ccxt 基于 requests

1154 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/792377

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX