2013-10-29 68 views
0

我们如何使用Fiddler Core在机器根存储中安装Fiddler根证书? 我们可以使用certmgr来完成,但使用FiddlerCore可以很好地完成它。现在看来,这有方法来测试和安装的一切除了机器的根存储:(如何在机器根存储中安装Fiddler的根证书

FiddlerCore有以下方法:?

  • Fiddler.CertMaker.rootCertExists(),以“确定是否自签名的根证书存在“ 如果返回false,我们可以调用Fiddler.CertMaker.createRootCert()来安装证书。

  • Fiddler.CertMa ker.rootCertIsTrusted()来测试Fiddler的根证书是否在根存储中。 如果它返回false,我们可以拨打Fiddler.CertMaker.trustRootCert()来信任证书。

  • Fiddler.CertMaker.rootCertIsMachineTrusted()检查“在机器根存储提琴手的根证书?” 如果返回false ???我们要做什么来解决这个问题?

回答

5

本主题以及覆盖在Fiddler book,这是一个有益的参考与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; 
    }  

}

+0

感谢埃里克。我确实有这本书(它很棒),并且应该在那里检查一下:) –

相关问题