【问题标题】:Bypassing TLS certificate mismatch绕过 TLS 证书不匹配
【发布时间】:2017-12-25 18:16:44
【问题描述】:

我正在尝试使用 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]

Fiddler 内部:
200 HTTP Tunnel to 174.129.224.73:443 proxifier:5840
CONNECT 标头没有响应 (SessionID: empty)。 我还尝试了Protocols: <client>;ssl3;tls1.0;tls1.1;tls1.2
的组合 我在 java cacerts 中添加了 FiddlerRoot.cer
我会欣赏更多的想法。

编辑 2
我安装了多个 java 版本,并将证书添加到错误的密钥库中。 最终的解决方案确实是oSession["x-OverrideCertCN"] = "*.websocket.org"; inside OnBeforeRequest function + cacert update。

【问题讨论】:

  • 如果这不是生产,禁用主机名验证将是客户端上最简单的解决方案。

标签: java ssl websocket proxy fiddler


【解决方案1】:

最简单的机制是配置 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";
}

【讨论】:

  • 我有同样的问题,但上述解决方案似乎对我不起作用。
猜你喜欢
  • 1970-01-01
  • 2017-08-17
  • 1970-01-01
  • 1970-01-01
  • 2021-10-06
  • 2021-05-07
  • 2020-08-01
  • 2021-07-28
  • 2018-11-05
相关资源
最近更新 更多