V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yellowtail
V2EX  ›  Python

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

  •  
  •   yellowtail · 2021-07-29 02:52:26 +08:00 · 1113 次点击
    这是一个创建于 974 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境 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

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5296 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:10 · PVG 17:10 · LAX 02:10 · JFK 05:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.