繁体   English   中英

如何在机器根存储中安装Fiddler的根证书

[英]How to install Fiddler's root certificate in Machine Root store

我们如何使用Fiddler Core在机器根存储中安装Fiddler根证书? 我们可以使用certmgr做到这一点,但是使用FiddlerCore做到这一点将是很棒的。 似乎它具有测试和安装所有内容的方法,除了计算机根存储库:(!?

FiddlerCore具有以下方法:

  • Fiddler.CertMaker.rootCertExists()设置为“确定自签名根证书是否存在”,如果它返回false,则可以调用Fiddler.CertMaker.createRootCert ()来安装证书。

  • Fiddler.CertMaker.rootCertIsTrusted()测试Fiddler的根证书是否在Root存储区中。 如果返回false,我们可以调用Fiddler.CertMaker.trustRootCert ()信任证书。

  • Fiddler.CertMaker.rootCertIsMachineTrusted()检查“ Fiddler的根证书是否在计算机根存储中?”,如果它返回false? 我们该怎么解决这个问题?

这个主题在Fiddler的书中有很好的介绍,这是对FiddlerCore编程的有用参考。

要通过机器信任根,您的代码必须以管理员身份运行,并且必须使用.NET API:

private static bool setMachineTrust(X509Certificate2 oRootCert)
{
  try
  {
    X509Store certStore = new X509Store(StoreName.Root, 
                                        StoreLocation.LocalMachine);
    certStore.Open(OpenFlags.ReadWrite);

    try
    {
      certStore.Add(oRootCert);
    }
    finally
    {
      certStore.Close();
    }
    return true;
  }
  catch (Exception eX) 
  {
     return false;
  }    

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM