简体   繁体   English

Python Twisted:SSL例程,ssl3_get_server_certificate错误

[英]Python Twisted : SSL routines , ssl3_get_server_certificate errors

I am using the check_server_certificate.py code example from http://twistedmatrix.com/documents/current/core/howto/ssl.html in order to get a certificate from a public server . 我正在使用http://twistedmatrix.com/documents/current/core/howto/ssl.html中的check_server_certificate.py代码示例,以便从公共服务器获取证书。

from __future__ import print_function
import sys
from twisted.internet import defer, endpoints, protocol, ssl, task, error

def main(reactor, host, port=443):
    options = ssl.optionsForClientTLS(hostname=host.decode('utf-8'))
    port = int(port)

    class ShowCertificate(protocol.Protocol):
        def connectionMade(self):
            self.transport.write(b"GET / HTTP/1.0\r\n\r\n")
            self.done = defer.Deferred()
        def dataReceived(self, data):
            certificate = ssl.Certificate(self.transport.getPeerCertificate())
            print("OK:", certificate)
            self.transport.abortConnection()
        def connectionLost(self, reason):
            print("Lost.")
            if not reason.check(error.ConnectionClosed):
                print("BAD:", reason.value)
            self.done.callback(None)

    return endpoints.connectProtocol(
        endpoints.SSL4ClientEndpoint(reactor, host, port, options),
        ShowCertificate()
    ).addCallback(lambda protocol: protocol.done)

task.react(main, sys.argv[1:])

Having installed the necessary “service_identity” and “idna” packages from PyPI and still getting this error : 从PyPI安装了必要的“service_identity”和“idna”软件包后仍然出现此错误:

$ python check_server_certificate.py www.twistedmatrix.com
Lost.
BAD: [('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')]

any ideas? 有任何想法吗?

SSL_CERT_FILE = "$(python -m certifi)" 
python check_server_certificate.py www.twistedmatrix.com

Try to use this, it worked for me. 尝试使用它,它对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在python中抑制'SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败'错误 - Suppress 'SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' errors in python SSL错误:例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - SSL error : routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 身份验证失败:[Errno 1] _ssl.c:510:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - Authentication failed: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed SSLError:[Errno 1] _ssl.c:510:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 请求(仅)* .google.com时,SSL上的SSL3_GET_SERVER_CERTIFICATE证书验证失败 - SSL3_GET_SERVER_CERTIFICATE certificate verify failed on Python when requesting (only) *.google.com Python Twisted SSL的证书生成 - Certificate Generation for Python Twisted SSL SSL 错误 ssl.get_server_certificate 在某些网站上但在其他网站上没有 - SSL Errors for ssl.get_server_certificate on some websites but not on others 如何验证双绞线SSL客户端中的SSL服务器证书 - How to validate the SSL server certificate in twisted SSL client Python HTTPS/SSL 错误:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 警报协议版本 - Python HTTPS/SSL error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version Python ssl.get_server_certificate 下载错误的证书? - Python ssl.get_server_certificate downloads wrong certificate?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM