Tiago Andrade e Silva
Tiago Andrade e Silva

Reputation: 986

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

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:

Upvotes: 1

Views: 2481

Answers (1)

EricLaw
EricLaw

Reputation: 57115

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

}

Upvotes: 5

Related Questions