Discord.py无法获得证书 [英] Discord.py unable to get certificate

查看:256
本文介绍了Discord.py无法获得证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否必须在系统内安装/生成/下载新证书,或者我是否有可能以某种方式禁用python内的证书? ( ubuntu 18,python 3.7,discord.py最新

Do I have to install/generate/download new certificate inside my system or is it possible for me somehow to disable certificates inside the python? (ubuntu 18, python 3.7, discord.py latest)

[INFO]  [2019.03.05 - 22:58:02]   Initializing Discord...

SSL handshake failed on verifying the certificate
protocol: <asyncio.sslproto.SSLProtocol object at 0xf4a9f8ec>
transport: <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "./build/Lib/asyncio/sslproto.py", line 625, in _on_handshake_complete
  File "./build/Lib/asyncio/sslproto.py", line 189, in feed_ssldata
  File "./build/Lib/ssl.py", line 763, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)

SSL error in data received
protocol: <asyncio.sslproto.SSLProtocol object at 0xf4a9f8ec>
transport: <_SelectorSocketTransport closing fd=12 read=idle write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "./build/Lib/asyncio/sslproto.py", line 526, in data_received
  File "./build/Lib/asyncio/sslproto.py", line 189, in feed_ssldata
  File "./build/Lib/ssl.py", line 763, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)

[ERROR] [2019.03.05 - 22:58:02]   
2019.03.05 - 22:58:02:
  Top:  file: [sv_custom.py], method: init()
  Root: file: [connector.py], line 974, cause: in _create_direct_connection [File "./../source/aiohttp.whl/aiohttp/connector.py", line 927, in _wrap_create_connection]
  aiohttp.client_exceptions.ClientConnectorCertificateError:
  Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)')]



< >是通过游戏客户端内部的python完成的。如果我从系统的python(3.6)执行相同操作-没有错误,则表示连接正常。 他们说可能是因为游戏客户端看不到根证书或类似的东西。

This is done from the python that is inside the game client. If I do the same from the system's python (3.6) - no errors, connection is fine. "They say" it could be because the game client does not see "root certificates" or something like that.

更新:
了解如何检查证书。

Update: Found out how to check certificates.

(with ssl error)
Initializing Discord...
DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/usr/local/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/usr/local/ssl/certs')


(this works fine)
igor@Linbox:~/Downloads$ python3.6 -c "import ssl; print(ssl.get_default_verify_paths())"
DefaultVerifyPaths(cafile=None, capath='/usr/lib/ssl/certs', openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/usr/lib/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/usr/lib/ssl/certs')

猜猜这是我的问题, capath 为空。

Guess that is my problem that capath is empty.

推荐答案

出乎意料的是,解决方案看起来很简单:

Unexpectedly the solution appeared quite simple:

ssl.get_default_verify_paths() ssl错误指向: open ssl_capath ='/ usr / local / ssl / certs',而系统中的本地 python显示 openssl_capath ='/ usr / lib / ssl / certs'

ssl.get_default_verify_paths() for the python with the ssl error was pointing to: openssl_capath='/usr/local/ssl/certs' while the "native" python from the system showed openssl_capath='/usr/lib/ssl/certs'.

DefaultVerifyPaths(
  cafile=None,
  capath=None,
  openssl_cafile_env='SSL_CERT_FILE',
  openssl_cafile='/usr/local/ssl/cert.pem',
  openssl_capath_env='SSL_CERT_DIR',
  openssl_capath='/usr/local/ssl/certs'
)

我已经检查了两个位置:
'/ usr / local /'-为空(没有 ssl / certs 文件夹)
'/ usr / lib / ssl / certs''/ etc / ssl / certs'
有一个符号链接进行了相同的符号链接:'/ usr / local /'内的
添加了'/ ssl /' + ln -s'/ etc / ssl / certs'证书

I've checked both locations: '/usr/local/' - was empty (it had no ssl/certs folders) '/usr/lib/ssl/certs' had a symlink to '/etc/ssl/certs' So I made the same symlink: inside '/usr/local/' added '/ssl/' + ln -s '/etc/ssl/certs' certs

然后我再次检查了 ssl.get_default_verify_paths()

DefaultVerifyPaths(
  cafile=None,
  capath='/usr/local/ssl/certs',  <-- not empty now
  openssl_cafile_env='SSL_CERT_FILE',
  openssl_cafile='/usr/local/ssl/cert.pem',
  openssl_capath_env='SSL_CERT_DIR',
  openssl_capath='/usr/local/ssl/certs'
)

问题消失了。现在正在工作。

The problem disappeared. It is working now.

这篇关于Discord.py无法获得证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆