捕获 MITM 代理内联脚本中的 SSL 验证错误

Capture SSL Verification Error in MITM Proxy inline script

我正在使用 MITM Proxy to capture requests/responses using Python Inline Scripts。如果证书验证错误,MITM 代理将日志行写入标准输出,如

127.0.0.1:34390: SSL verification failed for upstream server at depth 0 with error: 18

是否可以在内联脚本函数中捕获此证书验证错误?如何捕获?我只能在此脚本中捕获 http 请求和响应。 如果使用内联脚本不可能,也许我可以使用 libmproxy?

我运行遇到了同样的问题。值得庆幸的是,mitmproxy 的代码非常干净且组织良好。您将能够像这样检索错误:

def request(context, flow):
    print flow.server_conn.ssl_verification_error