mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +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:
|
if handle_sni:
|
||||||
# SNI callback happens during do_handshake()
|
# SNI callback happens during do_handshake()
|
||||||
ctx.set_tlsext_servername_callback(handle_sni)
|
ctx.set_tlsext_servername_callback(handle_sni)
|
||||||
ctx.use_privatekey_file(key)
|
ctx.use_privatekey(key)
|
||||||
ctx.use_certificate(cert.x509)
|
ctx.use_certificate(cert.x509)
|
||||||
if request_client_cert:
|
if request_client_cert:
|
||||||
def ver(*args):
|
def ver(*args):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import threading, Queue, cStringIO
|
import threading, Queue, cStringIO
|
||||||
import tcp, certutils
|
import tcp, certutils
|
||||||
|
import OpenSSL
|
||||||
|
|
||||||
class ServerThread(threading.Thread):
|
class ServerThread(threading.Thread):
|
||||||
def __init__(self, server):
|
def __init__(self, server):
|
||||||
@ -49,6 +50,8 @@ class TServer(tcp.TCPServer):
|
|||||||
self.handler_klass = handler_klass
|
self.handler_klass = handler_klass
|
||||||
self.last_handler = None
|
self.last_handler = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def handle_client_connection(self, request, client_address):
|
def handle_client_connection(self, request, client_address):
|
||||||
h = self.handler_klass(request, client_address, self)
|
h = self.handler_klass(request, client_address, self)
|
||||||
self.last_handler = h
|
self.last_handler = h
|
||||||
@ -56,6 +59,8 @@ class TServer(tcp.TCPServer):
|
|||||||
cert = certutils.SSLCert.from_pem(
|
cert = certutils.SSLCert.from_pem(
|
||||||
file(self.ssl["cert"], "rb").read()
|
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"]:
|
if self.ssl["v3_only"]:
|
||||||
method = tcp.SSLv3_METHOD
|
method = tcp.SSLv3_METHOD
|
||||||
options = tcp.OP_NO_SSLv2|tcp.OP_NO_TLSv1
|
options = tcp.OP_NO_SSLv2|tcp.OP_NO_TLSv1
|
||||||
@ -63,8 +68,7 @@ class TServer(tcp.TCPServer):
|
|||||||
method = tcp.SSLv23_METHOD
|
method = tcp.SSLv23_METHOD
|
||||||
options = None
|
options = None
|
||||||
h.convert_to_ssl(
|
h.convert_to_ssl(
|
||||||
cert,
|
cert, key,
|
||||||
self.ssl["key"],
|
|
||||||
method = method,
|
method = method,
|
||||||
options = options,
|
options = options,
|
||||||
handle_sni = getattr(h, "handle_sni", None),
|
handle_sni = getattr(h, "handle_sni", None),
|
||||||
|
Loading…
Reference in New Issue
Block a user