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"); ... } } }