绕过 TLS 证书不匹配
Bypassing TLS certificate mismatch
我正在尝试使用 Fiddler 捕获基于 https://github.com/TakahikoKawasaki/nv-websocket-client 的 java 客户端和服务器 wss://echo.websocket.org 之间的 websocket 通信。我可以通过使用 Proxifier 或 ProxyCap 将客户端重定向到 localhost:8888 来监听非安全连接 (ws://)。然而,使用 TLS 我得到一个错误:The certificate of the peer does not match the expected hostname (echo.websocket.org)
。如何在不修改客户端源代码的情况下解决这个问题?使用浏览器(chrome/firefox)我可以毫无问题地看到所有内容(我信任 Fiddler 的根证书)。我正在使用 Windows 7.
编辑 更多信息:
我尝试了 EricLaw 解决方案,但结果是一样的。我在客户端打印验证步骤:
//direct connection:
(SocketConnector)mSocket.InetAddress: echo.websocket.org/174.129.224.73
(SocketConnector)mSocket.getLocalSocketAddress: /192.168.0.100:2044
(SSLSession)verify: host=echo.websocket.org
(SSLSession)verify: cipher suite=TLS_RSA_WITH_AES_128_CBC_SHA256
(SSLSession)verify: peer host=echo.websocket.org
(SSLSession)verify: session.toString=[Session-1,
TLS_RSA_WITH_AES_128_CBC_SHA256]
verifyHostName: hostName=echo.websocket.org, pattern=*.websocket.org
VERIFIED!
//proxy+fiddler:
(SocketConnector)mSocket.InetAddress: echo.websocket.org/174.129.224.73
(SocketConnector)mSocket.getLocalSocketAddress: /127.0.0.1:2039
(SSLSession)verify: host=echo.websocket.org
(SSLSession)verify: cipher suite=SSL_NULL_WITH_NULL_NULL
(SSLSession)verify: peer host=null
(SSLSession)verify: session.toString=[Session-1, SSL_NULL_WITH_NULL_NULL]
提琴手内部:
200 HTTP Tunnel to 174.129.224.73:443 proxifier:5840
CONNECT
header (SessionID: empty
) 没有响应。
我还尝试了 Protocols: <client>;ssl3;tls1.0;tls1.1;tls1.2
的组合
我将 FiddlerRoot.cer
添加到 java cacerts.
我会很感激更多的想法。
编辑 2
我安装了多个 java 版本,并将证书添加到错误的密钥库。
最终的解决方案确实是 oSession["x-OverrideCertCN"] = "*.websocket.org";
inside OnBeforeRequest
function + cacert update.
最简单的机制是将 Fiddler 配置为将证书的主机名设置为 echo.websocket.org
(或其他)。
// Put the correct IP address or hostname in the next line.
if (oSession.uriContains("1.2.3.4")) {
oSession["x-OverrideCertCN"] = "*.websocket.org";
}
我正在尝试使用 Fiddler 捕获基于 https://github.com/TakahikoKawasaki/nv-websocket-client 的 java 客户端和服务器 wss://echo.websocket.org 之间的 websocket 通信。我可以通过使用 Proxifier 或 ProxyCap 将客户端重定向到 localhost:8888 来监听非安全连接 (ws://)。然而,使用 TLS 我得到一个错误:The certificate of the peer does not match the expected hostname (echo.websocket.org)
。如何在不修改客户端源代码的情况下解决这个问题?使用浏览器(chrome/firefox)我可以毫无问题地看到所有内容(我信任 Fiddler 的根证书)。我正在使用 Windows 7.
编辑 更多信息:
我尝试了 EricLaw 解决方案,但结果是一样的。我在客户端打印验证步骤:
//direct connection:
(SocketConnector)mSocket.InetAddress: echo.websocket.org/174.129.224.73
(SocketConnector)mSocket.getLocalSocketAddress: /192.168.0.100:2044
(SSLSession)verify: host=echo.websocket.org
(SSLSession)verify: cipher suite=TLS_RSA_WITH_AES_128_CBC_SHA256
(SSLSession)verify: peer host=echo.websocket.org
(SSLSession)verify: session.toString=[Session-1,
TLS_RSA_WITH_AES_128_CBC_SHA256]
verifyHostName: hostName=echo.websocket.org, pattern=*.websocket.org
VERIFIED!
//proxy+fiddler:
(SocketConnector)mSocket.InetAddress: echo.websocket.org/174.129.224.73
(SocketConnector)mSocket.getLocalSocketAddress: /127.0.0.1:2039
(SSLSession)verify: host=echo.websocket.org
(SSLSession)verify: cipher suite=SSL_NULL_WITH_NULL_NULL
(SSLSession)verify: peer host=null
(SSLSession)verify: session.toString=[Session-1, SSL_NULL_WITH_NULL_NULL]
提琴手内部:
200 HTTP Tunnel to 174.129.224.73:443 proxifier:5840
(CONNECT
headerSessionID: empty
) 没有响应。
我还尝试了 Protocols: <client>;ssl3;tls1.0;tls1.1;tls1.2
的组合
我将 FiddlerRoot.cer
添加到 java cacerts.
我会很感激更多的想法。
编辑 2
我安装了多个 java 版本,并将证书添加到错误的密钥库。
最终的解决方案确实是 oSession["x-OverrideCertCN"] = "*.websocket.org";
inside OnBeforeRequest
function + cacert update.
最简单的机制是将 Fiddler 配置为将证书的主机名设置为 echo.websocket.org
(或其他)。
// Put the correct IP address or hostname in the next line.
if (oSession.uriContains("1.2.3.4")) {
oSession["x-OverrideCertCN"] = "*.websocket.org";
}