> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/pam/administration/audit/certificate-and-key-audit.md). Agents can also search and read this documentation through its [MCP server](https://wiki.datadike.com/~gitbook/mcp).

# Certificate and PGP key audit

Follow every replacement, renewal, deployment, alert and export of SSL/TLS certificates and PGP keys, including what the solution does on its own.

## What this is and when to use it

Every action on a managed certificate or PGP key is recorded as an event: who did it, from which IP address, when, and what changed. The actions the solution takes by itself are recorded too: the daily check, the automatic renewals and rotations, the alerts, and the changes it detects on the servers.

Use these trails to answer when a certificate was replaced and by whom, why a renewal failed, which keys were exported, and whether a key was changed on a server without going through the solution.

There are two trails:

| Trail        | Where                              | What it covers                                                                                                                    |
| ------------ | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Certificates | **Audit › Console › Certificates** | Certificates added, changed, removed, checked, renewed, deployed and replaced, expiration alerts, discovery runs                  |
| PGP keys     | **Audit › Console › PGP keys**     | Keys discovered, generated, imported, collected, installed, rotated and exported, changes found on the servers, expiration alerts |

Each certificate and each key also has an **Audit** tab with its own **Timeline**.

## Before you start

* A role that can view the certificate or PGP key events. The auditor role can see both trails without permission to change certificates or keys.

## Steps

1. Open **Audit › Console › Certificates** or **Audit › Console › PGP keys**.
2. Narrow the list:
   * Type in the search box a certificate name, an address, a key fingerprint or a user name.
   * Click **Filter** to choose the **Event type** and the **Result**.
   * Sort by **Newest first** or **Oldest first**.
3. Click an event to open its details.

To see the history of a single item, open the certificate or the key and its **Audit** tab. **View in Audit > Certificates** or **View in Audit > PGP keys** opens the full trail filtered by that item.

## What you should see

Each event shows its type, the certificate or key, the user, the IP address, the time and the result: **Information**, **Success**, **Warning** or **Error**. Events started by the solution itself, such as the daily check or an automatic renewal, show **System** as the user.

The details of an event show:

* **Details**: the data of the event, such as the old and new fingerprint of a replaced certificate, the renewal method, the subkeys created in a rotation, or the error of a failed operation.
* **Changes**: for **Settings changed**, each field changed with its value **Before** and **After**. Private keys, passphrases and other secrets never appear in the trail.

### Certificate events

| Event                                                                  | Recorded when                                                                                  |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| **Certificate added** / **Settings changed** / **Certificate removed** | Someone adds, edits or removes a certificate in the inventory                                  |
| **Found by discovery** / **Discovery run**                             | A discovery plan finds a certificate / finishes a run                                          |
| **Status changed**                                                     | The status changes, for example from **Valid** to **Expiring** or **Unreachable**              |
| **Certificate replaced on the server**                                 | The server presents a different certificate from the one in the inventory, whoever replaced it |
| **Expiration alert**                                                   | An expiration alert is sent                                                                    |
| **Renewal started** / **CSR generated**                                | A renewal starts / a CSR is created for your CA                                                |
| **Certificate received** / **Signed certificate refused**              | A new certificate is issued or uploaded / an uploaded certificate does not match the key       |
| **Certificate deployed**                                               | The certificate is installed and confirmed on the endpoint                                     |
| **Renewal failed** / **Renewal canceled**                              | A renewal fails, with the reason / is canceled                                                 |

### PGP key events

| Event                                                         | Recorded when                                            |
| ------------------------------------------------------------- | -------------------------------------------------------- |
| **Key generated** / **Key imported**                          | A key is created in the solution or imported             |
| **Found by discovery** / **Discovery run**                    | A discovery plan finds a key / finishes a run            |
| **Private key in custody**                                    | A private key is collected from an asset into the vault  |
| **Key installed on the asset**                                | A key is installed in the keyring of a user on an asset  |
| **Subkeys rotated** / **Rotation failed**                     | A rotation completes / fails, with the reason            |
| **Key changed on the asset** / **Key no longer on the asset** | Discovery finds the key changed or removed on the server |
| **Private key exported**                                      | Someone displays the private key                         |
| **Status changed** / **Expiration alert**                     | The status changes / an expiration alert is sent         |
| **Operation failed**                                          | Collecting or installing a key fails                     |
| **Settings changed** / **Key removed**                        | Someone edits or removes a key in the inventory          |

## How to verify it worked

1. Open a certificate and click **Check now**. Then open its **Audit** tab: the check must not add an event if nothing changed.
2. Edit the certificate, change **Name**, and save. **Audit › Console › Certificates** must show **Settings changed**, with your user and IP address, and the old and new name under **Changes**.
3. If syslog forwarding is configured, the same event must reach the collector, in the `certificate_log` category for certificates and `pgp_key_log` for PGP keys.

## Forwarding to a SIEM

Certificate and PGP key events are forwarded together with the other audit records when syslog forwarding is configured. See [Syslog and SIEM](https://wiki.datadike.com/pam/administration/integrations/syslog-and-siem.md).

## Common errors

| Symptom                                                                           | Cause                                                                                                       | Fix                                                                                                                          |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| The menu does not show **Certificates** or **PGP keys** under **Audit › Console** | The role cannot view those events                                                                           | Grant the view permission for certificate or PGP key events to the role                                                      |
| An event shows **System** as the user                                             | The solution acted on its own: the daily check, a scheduled discovery run, an automatic renewal or rotation | Nothing to fix                                                                                                               |
| The events do not reach the SIEM                                                  | Syslog forwarding is not configured                                                                         | Configure it as described in [Syslog and SIEM](https://wiki.datadike.com/pam/administration/integrations/syslog-and-siem.md) |

## Related pages

* [Audit trail](https://wiki.datadike.com/pam/administration/audit/audit-trail.md)
* [Monitor SSL/TLS certificates](https://wiki.datadike.com/pam/administration/certificates/monitoring.md)
* [Renew and deploy certificates](https://wiki.datadike.com/pam/administration/certificates/renewal.md)
* [Discover and keep PGP keys in custody](https://wiki.datadike.com/pam/administration/pgp-keys/custody.md)
* [Rotate PGP subkeys](https://wiki.datadike.com/pam/administration/pgp-keys/rotation.md)
