默认情况下 wireshark 抓到的https 数据包都是加密后的,无法展示明文内容

方式一 -SSLKEYLOGFILE 变量方式 【推荐,适用各种情况】

配置环境变量

浏览器在访问https 站点的时候会检测这个SSLKEYLOGFILE 变量,如果存在,则将https 密钥写入对应的文件内

配置好之后需要重启浏览器生效

文件内容如下

配置wireshark

配置wireshark 使用上面环境变量指定的密钥文件

方式二 – RSA 密钥方式【有局限性】

适用如下情形

The cipher suite selected by the server is not using (EC)DHE.The protocol version is SSLv3, (D)TLS 1.0-1.2. It does not work with TLS 1.3.The private key matches the server certificate. It does not work with the client certificate, nor the Certificate Authority (CA) certificate.The session has not been resumed. The handshake must include the ClientKeyExchange handshake message.

将服务端的 RSA 密钥放入wireshark 的下面配置中

运行wireshark 解密https

先运行wireshark ,然后再访问目标网站,可以看到已经有 http2 协议的内容了,可以看到明文
如果不生效,可以看下是否再打开wireshark 前已经访问过目标网站了,可以重新关闭浏览器,然后再打开wireshark