# Using Client Certificates

Some HTTPS servers request a client certificate to authenticate the connecting client. When Fiddler Everywhere captures and decrypts HTTPS traffic, it can present a configured client certificate during the TLS handshake with the server.

The client certificate identifies Fiddler Everywhere on the **Fiddler-to-server** connection. It is separate from the Fiddler root CA certificate, which clients use to trust the HTTPS certificates generated by Fiddler. Configuring a client certificate does not change the certificate that a client application presents to Fiddler.

## Prerequisites and Supported Formats

1. [Trust the Fiddler root CA and enable HTTPS capturing](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/user-guide/settings/https). Make sure the target traffic goes through Fiddler and is decrypted.
2. Obtain a client certificate that the server accepts and its matching private key.
3. Provide the certificate in one of the following formats:

   | Format           | Private key                                                                                                                                                |
   | :--------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `.pfx` or `.p12` | Included in the PKCS#12 file. The file must not be password-protected.                                                                                     |
   | `.pem`           | An unencrypted key in the same file or in a sibling key file, such as `client.key` for `client.pem`.                                                       |
   | `.cer` or `.crt` | A matching certificate with a private key in an available OS certificate store. A PEM-encoded certificate can also use an unencrypted sibling `.key` file. |

Encrypted PEM private keys and password-protected PKCS#12 files are not supported. On Windows, Fiddler searches the personal certificate stores of the current user and local machine; on macOS and Linux, it searches the current user's personal store where available. Importing a public certificate alone does not install its private key.

> important Unencrypted private keys are sensitive. Restrict access to certificate and key files, and do not share or commit them.

## Configure a Default Client Certificate

The default certificate is available to servers that request client authentication; it is not sent to servers that do not request it.

1. Open **Settings** > **HTTPS** and find **Client certificate**.
2. Enter the certificate file path or select **Browse** and choose the file.
3. Select **Validate** to check that Fiddler can load the certificate and private key. Address any error or validity warning.
4. Select **Save**.

Validation does not establish that the server trusts the certificate or will accept it for client authentication. To verify the complete flow, send a new request to the server and check its response or server-side authentication logs.

### Use the Default Certificate Directory

Alternatively, leave the **Client certificate** setting empty and place the certificate in `~/.fiddler/ClientCertificates`, where `~` is the current user's home directory. On Windows, this is typically `%USERPROFILE%\.fiddler\ClientCertificates`. Use one of these exact file names:

`ClientCertificate.pfx`, `ClientCertificate.p12`, `ClientCertificate.pem`, `ClientCertificate.crt`, or `ClientCertificate.cer`.

If multiple files exist, Fiddler checks them in the order listed above. For a separate PEM key, use the matching name `ClientCertificate.key`. The field in **Settings** > **HTTPS** shows the default directory when empty; you can select **Validate** to check the default certificate. **Clear** removes an explicit path and restores default-directory lookup after you save the settings.

## Select a Certificate with a Rule

Use the **Use client certificate** rule action to select a certificate for a destination instead of the default certificate:

1. Open the **Rules** tab and select **Add Rule**.
2. Add a condition that matches the destination host and port on the HTTPS **CONNECT** request. Do not rely on a URL path in the decrypted request: the certificate is selected before that request is available.
3. Add the **Use client certificate** action and enter the certificate file path, or select **Browse...** to choose it.
4. Save and enable the rule, and turn on the main **Rules** switch.
5. Start a new connection to the destination and check the server's response or authentication logs.

The action is non-final and applies to newly captured CONNECT requests with HTTPS capturing enabled. It selects a certificate for the connection, not individual requests within it. A relative path is resolved from the default `ClientCertificates` directory; an absolute path is used as provided. For more information about creating rules, see [Modifying Traffic](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/modify-and-filter-traffic/modify-traffic-with-rules).

## Select a Certificate with a Script

You can set the `https-Client-Certificate` session flag in an `OnBeforeRequest` hook. For example, the following script selects a certificate for a CONNECT request to `secure.example.com` on port `443`:

```csharp
void OnBeforeRequest(Session oSession)
{
    if (oSession.HTTPMethodIs("CONNECT") && oSession.PathAndQuery == "secure.example.com:443")
    {
        oSession["https-Client-Certificate"] = @"C:\certificates\client.pfx";
    }
}
```

Replace the host, port, and path with your own values. For macOS or Linux, use an appropriate absolute path, or use a path relative to the default `ClientCertificates` directory. Save and enable the script and the main **Scripting** switch before starting a new connection. See [Scripting Overview](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/scripting/scripting-overview) for details.

## Selection and Connection Reuse

A certificate selected by a rule or session flag takes precedence over the certificate configured in HTTPS settings. If there is no explicit selection, Fiddler uses the configured default path, or the default-directory file when the setting is empty. If an explicitly selected rule or session certificate cannot be loaded, the upstream TLS connection fails instead of falling back to the default certificate.

Use one client-certificate identity per destination host and port. Upstream HTTP/1 connections can be reused without considering the selected certificate, so changing a rule or script does not change the identity of an existing connection or guarantee a new TLS handshake. If testing a different identity, ensure a fresh upstream connection and verify the identity at the server.

## Warnings and Troubleshooting

* When a server requests a client certificate and none is configured, Fiddler can display a warning and mark the session in the **Live Traffic** grid. The warning is deduplicated per host; on macOS it may not always appear.
* To suppress the warning, select **Don't show again** in the notification or enable **Don't warn when a site requests a client certificate** in **Settings** > **HTTPS**. Clear that setting and save to enable warnings again.
* If authentication fails, use **Validate**, check the certificate's validity and private key, and confirm that the server trusts the certificate and accepts it for client authentication.
* Verify that HTTPS capturing is enabled and the destination is decrypted. For a rule, ensure its condition matches the CONNECT destination rather than only a decrypted request path.
* If a different certificate is presented than expected, check the selection order and connection reuse. If no certificate is presented, check whether the server actually requests one; an optional client-certificate request can succeed without an authenticated client.

## See Also

* [HTTPS Settings](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/user-guide/settings/https)
* [Using Conditions and Actions](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/modify-and-filter-traffic/conditions-and-actions)
* [Common Scripting Examples](https://www.telerik.com/fiddler/fiddler-everywhere/documentation/scripting/script-examples)
