Class
CertMaker

This class is used to find and create certificates for use in HTTPS interception. The default implementation (DefaultCertProvider object) uses the Windows Certificate store, but if a plugin ICertificateProvider is provided, it is used instead.

Definition

Namespace:Fiddler

Assembly:FiddlerCore.dll

Syntax:

cs-api-definition
public class CertMaker

Inheritance: objectCertMaker

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()

Constructors

CertMaker()

Declaration

cs-api-definition
public CertMaker()

Fields

oCertProvider

Enables specification of a delegate certificate provider that generates certificates for HTTPS interception.

Declaration

cs-api-definition
public static ICertificateProvider oCertProvider

Field Value

ICertificateProvider

Methods

ClearCertificateCache(bool, out CertificateStoreOperationStatus)

Removes Fiddler-generated certificates from the Windows certificate store

Declaration

cs-api-definition
public static bool ClearCertificateCache(bool bRemoveRoot, out CertificateStoreOperationStatus status)

Parameters

bRemoveRoot

bool

Indicates whether Root certificates should also be cleaned up

status

CertificateStoreOperationStatus

Status of add/remove operation to store

Returns

bool

CreateRootCertificate()

Create a self-signed root certificate to use as the trust anchor for HTTPS interception certificate chains

Declaration

cs-api-definition
public static bool CreateRootCertificate()

Returns

bool

TRUE if successful

DoDispose()

Dispose of the Certificate Provider, if any.

Declaration

cs-api-definition
public static void DoDispose()

EnsureReady()

Ensures that the Certificate Generator is ready; thread-safe

Declaration

cs-api-definition
public static void EnsureReady()

FindCert(string)

Request a certificate with the specified SubjectCN

Declaration

cs-api-definition
public static X509Certificate2 FindCert(string sHostname)

Parameters

sHostname

string

A string of the form: "www.hostname.com"

Returns

X509Certificate2

A certificate or /null/ if the certificate could not be found or created

GetCertProviderInfo()

Gets the name of the current certificate provider instance used to create Fiddler certificates

Declaration

cs-api-definition
public static string GetCertProviderInfo()

Returns

string

The name and location of the certificate provider instance

GetRootCertificate()

Returns the Root certificate that Fiddler uses to generate per-site certificates used for HTTPS interception.

Declaration

cs-api-definition
public static X509Certificate2 GetRootCertificate()

Returns

X509Certificate2

Returns the root certificate, if present, or null if the root certificate does not exist.

HasRootCertificate()

Checks if the current certificate provider has generated a Root certificate authority.

Declaration

cs-api-definition
public static bool HasRootCertificate()

Returns

bool

True if root certificate is valid and loaded

IsRootCertificateTrusted()

Is Fiddler's root certificate in the Root store?

Declaration

cs-api-definition
public static bool IsRootCertificateTrusted()

Returns

bool

TRUE if so

IsRootCertificateTrustedMachine()

Is Fiddler's root certificate in the Machine Root store? This method works only on Windows platforms.

Declaration

cs-api-definition
public static bool IsRootCertificateTrustedMachine()

Returns

bool

TRUE if so

ReadRootCertificateAndPrivateKeyFromPkcs12File(string, string, string)

When this method is called, your extension should read the root certificate and its private key from the PKCS#12 file(.pfx | .p12).

Declaration

cs-api-definition
public static void ReadRootCertificateAndPrivateKeyFromPkcs12File(string filename, string password, string alias = null)

Parameters

filename

string

The filename of the PKCS#12 file (.pfx | .p12).

password

string

The password which is used to protect the private key. Could be null or empty if the private key is not protected.

alias

string

The alias for the certificate and the private key. Could be null.

StoreCert(string, X509Certificate2)

Pre-cache a Certificate in the Certificate Maker that should be returned in subsequent calls to FindCert

Declaration

cs-api-definition
public static bool StoreCert(string sHost, X509Certificate2 oCert)

Parameters

sHost

string

The hostname for which this certificate should be returned.

oCert

X509Certificate2

The X509Certificate2 with attached Private Key

Returns

bool

TRUE if the Certificate Provider succeeded in pre-caching the certificate. FALSE if Provider doesn't support pre-caching. THROWS if supplied Certificate lacks Private Key.

StoreCert(string, string, string)

Pre-cache a Certificate in the Certificate Maker that should be returned in subsequent calls to FindCert

Declaration

cs-api-definition
public static void StoreCert(string sHost, string sPFXFilename, string sPFXPassword)

Parameters

sHost

string

The hostname for which this certificate should be returned.

sPFXFilename

string

The filename of the PFX file containing the certificate and private key

sPFXPassword

string

The password for the PFX file

TrustRootCertificate()

Finds the Fiddler root certificate and prompts the user to add it to the user TRUSTED store. Note: The system certificate store is used by most applications (IE, Chrome, etc) but not all; for instance, Firefox uses its own certificate store.

Declaration

cs-api-definition
public static bool TrustRootCertificate()

Returns

bool

True if successful

TrustRootCertificateMachine()

Finds the Fiddler root certificate and prompts the user to add it to the machine TRUSTED store. Note: The system certificate store is used by most applications (IE, Chrome, etc) but not all; for instance, Firefox uses its own certificate store.

Declaration

cs-api-definition
public static bool TrustRootCertificateMachine()

Returns

bool

True if successful

WriteRootCertificateAndPrivateKeyToPkcs12File(string, string, string)

Save the root certificate and its private key to a PKCS#12 file(.pfx | .p12).

Declaration

cs-api-definition
public static void WriteRootCertificateAndPrivateKeyToPkcs12File(string filename, string password, string alias = null)

Parameters

filename

string

The filename of the PKCS#12 file (.pfx | .p12).

password

string

The password which is used to protect the private key. If null or empty, the private key is written unprotected.

alias

string

The alias for the certificate and the private key. If null, a random alias could be created.

WriteRootCertificateToDerEncodedFile(string)

Save the root certificate excluding the private key to a DER encoded file(.cer | .crt | .der).

Declaration

cs-api-definition
public static void WriteRootCertificateToDerEncodedFile(string filename)

Parameters

filename

string

The filename of the DER encoded file (.cer | .crt | .der)

createRootCert()

Create a self-signed root certificate to use as the trust anchor for HTTPS interception certificate chains

Declaration

cs-api-definition
[Obsolete("Please use CreateRootCertificate() instead")]
public static bool createRootCert()

Returns

bool

TRUE if successful

removeFiddlerGeneratedCerts(bool, out CertificateStoreOperationStatus)

Removes Fiddler-generated certificates from the Windows certificate store

Declaration

cs-api-definition
[Obsolete("Please use ClearCertificateCache(bool, out CertificateStoreOperationStatus) instead")]
public static bool removeFiddlerGeneratedCerts(bool bRemoveRoot, out CertificateStoreOperationStatus status)

Parameters

bRemoveRoot

bool

Indicates whether Root certificates should also be cleaned up

status

CertificateStoreOperationStatus

Status of add/remove operation to store

Returns

bool

removeFiddlerGeneratedCerts(out CertificateStoreOperationStatus)

Removes Fiddler-generated certificates from the Windows certificate store

Declaration

cs-api-definition
[Obsolete("Please use ClearCertificateCache(true, out CertificateStoreOperationStatus) instead")]
public static bool removeFiddlerGeneratedCerts(out CertificateStoreOperationStatus status)

Parameters

status

CertificateStoreOperationStatus

Returns

bool

rootCertExists()

Determine if the self-signed root certificate exists

Declaration

cs-api-definition
[Obsolete("Please use HasRootCertificate() instead.")]
public static bool rootCertExists()

Returns

bool

True if the Root certificate returned from GetRootCertificate() is non-null, False otherwise.

rootCertIsMachineTrusted()

Is Fiddler's root certificate in the Machine Root store? This method works only on Windows platforms.

Declaration

cs-api-definition
[Obsolete("Please use IsRootCertificateTrustedMachine() instead")]
public static bool rootCertIsMachineTrusted()

Returns

bool

TRUE if so

rootCertIsTrusted()

Is Fiddler's root certificate in the Root store?

Declaration

cs-api-definition
[Obsolete("Please use IsRootCertificateTrusted() instead")]
public static bool rootCertIsTrusted()

Returns

bool

TRUE if so

trustRootCert()

Finds the Fiddler root certificate and prompts the user to add it to the TRUSTED store. Note: The system certificate store is used by most applications (IE, Chrome, etc) but not all; for instance, Firefox uses its own certificate store.

Declaration

cs-api-definition
[Obsolete("Please use TrustRootCertificate() instead")]
public static bool trustRootCert()

Returns

bool

True if successful

trustRootCertMachine()

Finds the Fiddler root certificate and prompts the user to add it to the machine TRUSTED store. Note: The system certificate store is used by most applications (IE, Chrome, etc) but not all; for instance, Firefox uses its own certificate store.

Declaration

cs-api-definition
[Obsolete("Please use TrustRootCertificateMachine() instead")]
public static bool trustRootCertMachine()

Returns

bool

True if successful