mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Handler convert_to_ssl now takes a key object, not a path.
This commit is contained in:
parent
0c3bc1cff2
commit
86730a9a4c
@ -375,7 +375,7 @@ class BaseHandler(_Connection):
|
||||
if handle_sni:
|
||||
# SNI callback happens during do_handshake()
|
||||
ctx.set_tlsext_servername_callback(handle_sni)
|
||||
ctx.use_privatekey_file(key)
|
||||
ctx.use_privatekey(key)
|
||||
ctx.use_certificate(cert.x509)
|
||||
if request_client_cert:
|
||||
def ver(*args):
|
||||
|
@ -1,5 +1,6 @@
|
||||
import threading, Queue, cStringIO
|
||||
import tcp, certutils
|
||||
import OpenSSL
|
||||
|
||||
class ServerThread(threading.Thread):
|
||||
def __init__(self, server):
|
||||
@ -49,6 +50,8 @@ class TServer(tcp.TCPServer):
|
||||
self.handler_klass = handler_klass
|
||||
self.last_handler = None
|
||||
|
||||
|
||||
|
||||
def handle_client_connection(self, request, client_address):
|
||||
h = self.handler_klass(request, client_address, self)
|
||||
self.last_handler = h
|
||||
@ -56,6 +59,8 @@ class TServer(tcp.TCPServer):
|
||||
cert = certutils.SSLCert.from_pem(
|
||||
file(self.ssl["cert"], "rb").read()
|
||||
)
|
||||
raw = file(self.ssl["key"], "rb").read()
|
||||
key = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, raw)
|
||||
if self.ssl["v3_only"]:
|
||||
method = tcp.SSLv3_METHOD
|
||||
options = tcp.OP_NO_SSLv2|tcp.OP_NO_TLSv1
|
||||
@ -63,8 +68,7 @@ class TServer(tcp.TCPServer):
|
||||
method = tcp.SSLv23_METHOD
|
||||
options = None
|
||||
h.convert_to_ssl(
|
||||
cert,
|
||||
self.ssl["key"],
|
||||
cert, key,
|
||||
method = method,
|
||||
options = options,
|
||||
handle_sni = getattr(h, "handle_sni", None),
|
||||
|
Loading…
Reference in New Issue
Block a user