我用Python Twisted(17.5.0)构建了一个TLS服务器,运行在python3.5.3上,代码如下:
from OpenSSL import crypto
from twisted.internet.ssl import (PrivateCertificate,KeyPair,Certificate)
from twisted.internet import reactor
from twisted.internet import protocol, task, defer
pkey_obj = open("server.key","rb").read()
pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, pkey_obj)
regsrv_obj = open("servercert.pem","rb").read()
regsrv_cert = crypto.load_certificate(crypto.FILETYPE_PEM, regsrv_obj)
certificate = Certificate(regsrv_cert)
prkey = KeyPair(pkey)
prkey_and_cert = PrivateCertificate.fromCertificateAndKeyPair(certificate, prkey)
tls_server_options = prkey_and_cert.options()
factory = protocol.Factory.forProtocol(Echo)
reactor.listenSSL(5444, factory, tls_server_options)
return defer.Deferred()
我改编自http://twistedmatrix.com/documents/current/core/howto/ssl.html
服务器通过以下命令正确启动并可用:
python3 tls_server.py
如果现在要使用openssl s_client查询此服务器,则服务器输出以下错误:
[Failure instance: Traceback: : [('SSL routines', 'tls_post_process_client_hello', 'no shared cipher')]
问:为什么服务器和客户端不能就一个通用密码达成一致?在
服务器的密钥是基于secp521r1的EC密钥,如果我用服务器的密钥/证书通过openssl s_server打开一个TLS服务器,它会完美地工作。我扭曲的实现一定有问题。在
编辑: 我试图用
nmap --script ssl-enum-ciphers -p 5444 localhost
但服务器似乎不提供任何密码或SSL功能。这是我在服务器端遇到的错误,如果我在底层twisted协议的die connectionLost()方法中输出错误:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐