FiddlerCore拦截Chrome的Htttps提示 "您的连接不是私密连接" NET::ERR_CERT_COMMON_NAME_INVALID
2020-08-26
问题导致
因为当前的FiddlerCore4.dll的版本太低,生成的ca证书不行,需要更换高级版本的FiddlerCore
解决方法:
-
去除原来项目引用的FiddlerCore.dll, CertMaker.dll ,BCMakeCert.dll
在 项目/项目名.csproj 搜索删除
-
下载 fiddlercore.4.6.2.nupkg 包
FiddlerCore Nuget 包(4.6.2) 下载地址:https://pan.baidu.com/s/1ueTCsJ5Jv7wovCeWVN4gDw
-
在VS2015项目导入 fiddlercore.4.6.2.nupkg
-
安装证书
public static void InstallCertificate() { //生成证书 CertMaker.createRootCert(); //获取证书 X509Certificate2 oRootcert = CertMaker.GetRootCertificate(); //把证书安装到受信任的根证书颁发机构 X509Store certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine); certStore.Open(OpenFlags.ReadWrite); try { certStore.Add(oRootcert); } finally { certStore.Close(); } //证书赋值 FiddlerApplication.oDefaultClientCertificate = oRootcert; //在解密HTTPS通信时,控制服务器证书错误是否被忽略。 CONFIG.IgnoreServerCertErrors = true; } namespace FiddlerTool { public partial class Form1 : Form { public Form1() { InitializeComponent(); // 安装证书 InstallCertificate(); //设置别名 Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp"); ... } } }