Question

How can we install the Fiddler root certificate in the machine root store using Fiddler Core ? We can do it with certmgr, but it would be great to do it using FiddlerCore. It seems it has methods to test and install everything except for the machine root store :( !?

FiddlerCore Has the following methods:

  • Fiddler.CertMaker.rootCertExists() to "Determine if the self-signed root certificate exists " if it returns false we can call Fiddler.CertMaker.createRootCert() to install the certificate.

  • Fiddler.CertMaker.rootCertIsTrusted() to test if Fiddler's root certificate is in the Root store. if it returns false we can call Fiddler.CertMaker.trustRootCert() to trust the certificate.

  • Fiddler.CertMaker.rootCertIsMachineTrusted() checks "Is Fiddler's root certificate in the Machine Root store? " if it returns false ??? what do we do to solve this ???

Was it helpful?

Solution

This topic is well-covered in the Fiddler book, which is a helpful reference to programming with FiddlerCore.

To machine-trust a root, your code must be running as Administrator and must use the .NET APIs:

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;
  }    

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top