![](/img/trans.png)
[英]Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
[英]ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed Python
我想使用SSL連接到IRC。 我用Python 2.7
編寫。 但是,對於以下代碼:
HOST = 'chat.freenode.net'
PORT = 7000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
code = sock.connect_ex((HOST, PORT))
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations('COMODOECCCertificationAuthority.crt')
secure_sock = context.wrap_socket(sock)
PyCharm在secure_sock = context.wrap_socket(sock)
行中顯示錯誤,這是什么問題?
context.load_verify_locations('COMODOECCCertificationAuthority.crt')
我不知道文件COMODOECCCertificationAuthority.crt
什么,但是看起來您期望由Comodo簽名的證書。 但是,chat.freenode.net證書的頒發者是Let's Encrypt,而不是Comodo。 您可以通過以下方式獲取鏈條
$ openssl s_client -connect chat.freenode.net:7000
...
Certificate chain
0 s:/CN=cherryh.freenode.net
i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
i:/O=Digital Signature Trust Co./CN=DST Root CA X3
這意味着您需要信任的根CA是“ DST根CA X3”。 您可以在此處下載此CA的證書。 如果您在load_verify_locations
中load_verify_locations
添加為受信任的load_verify_locations
它將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.