[英]How can I add SSL capabilities in twisted portforward proxy
我有以下用於portforward代理的代碼。 如何添加ssl支持,以便代理可以連接到使用ssl偵聽的服務器。
這是代碼:
from twisted.internet import reactor
from twisted.protocols import portforward
class ProxyServer(portforward.ProxyServer):
def dataReceived(self, data)
portforward.ProxyServer.dataReceived(self, data)
class ProxyFactory(portforward.ProxyFactory):
protocol = ProxyServer
reactor.listenTCP(8080,ProxyFactory("127.0.0.1",443) )
reactor.run()
檢查此鏈接。 此摘錄可能與您要尋找的內容有關。 https://twistedmatrix.com/documents/13.2.0/core/howto/ssl.html
with open('server.pem') as keyAndCert:
cert = ssl.PrivateCertificate.loadPEM(keyAndCert.read())
log.startLogging(sys.stdout)
factory = Factory()
factory.protocol = echoserv.Echo
reactor.listenSSL(8000, factory, cert.options())
reactor.run()
“請注意,在這些SSL版本中,來自回顯客戶端和服務器示例的TCP版本的所有協議代碼如何都是相同的(導入或重復的)-僅用於啟動網絡操作的反應器方法不同。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.