FiddlerCore拦截Chrome的Htttps提示 您的连接不是私密连接 NETERR_CERT_COMMON_NAME_INVALID


FiddlerCore拦截Chrome的Htttps提示 "您的连接不是私密连接" NET::ERR_CERT_COMMON_NAME_INVALID

2020-08-26

问题导致

因为当前的FiddlerCore4.dll的版本太低,生成的ca证书不行,需要更换高级版本的FiddlerCore

解决方法:

  1. 去除原来项目引用的FiddlerCore.dll, CertMaker.dll ,BCMakeCert.dll

    在 项目/项目名.csproj 搜索删除

  2. 下载 fiddlercore.4.6.2.nupkg 包

    FiddlerCore Nuget 包(4.6.2) 下载地址:https://pan.baidu.com/s/1ueTCsJ5Jv7wovCeWVN4gDw

  3. 在VS2015项目导入 fiddlercore.4.6.2.nupkg

    参考:vs2015离线使用nuget

  4. 安装证书

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

参考文档

使用 FiddlerCore 自定义 HTTP/HTTPS 网络代理

vs2015离线使用nuget


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM