1
我設計我在哪裏使用雙絞線它與SSL SSL服務器,它需要客戶端證書認證,繼續該計劃,當我驗證客戶端的SSL證書,則返回true,但我想通過commanname和EMAILADDRESS的客戶證書中,這樣我可以得到在處理程序類特定的客戶端設置,使你能幫助我嗎?扭曲的傳遞證書,SSL處理
from OpenSSL import SSL
from twisted.internet import ssl, reactor
from twisted.internet.protocol import Factory, Protocol
from twisted.web import server, resource, static, twcgi
class Handler(Protocol):
def dataReceived(self, data):
self.transport.write(data)
def connectionMade(self):
self.transport.write('hello world')
def verifyCallback(connection, x509, errnum, errdepth, ok):
global client_username
if not ok:
return False
else:
return True
if __name__ == '__main__':
#setting up ssl json server
factory = Factory()
factory.protocol = Handler
myContextFactory = ssl.DefaultOpenSSLContextFactory('server.key', 'server.crt',SSL.TLSv1_METHOD)
ctx = myContextFactory.getContext()
ctx.load_verify_locations("ca.crt")
ctx.set_verify(SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT,verifyCallback)
reactor.listenSSL(8080, factory,myContextFactory)
reactor.run()