> 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/certificates/monitoring.md). Agents can also search and read this documentation through its [MCP server](https://wiki.datadike.com/~gitbook/mcp).

# Monitor SSL/TLS certificates

Keep an inventory of the SSL/TLS certificates served on your network, find them with discovery plans, and get alerted before they expire.

## What this is and when to use it

**Environment › Certificates** keeps an inventory of the SSL/TLS certificates that your servers present: web servers, LDAPS, mail, WinRM over HTTPS and any other TLS service. For each one the solution records who issued it, the names it covers, the key and the expiration date. Every day it reads each certificate again and sends an alert when one is close to expiring.

Use it when an expired certificate would stop a service, and when you need to answer which certificates exist, where they are installed and when each of them expires.

The inventory is also the starting point for renewal. A certificate in the inventory can be renewed and installed by the solution itself; see [Renew and deploy certificates](https://wiki.datadike.com/pam/administration/certificates/renewal.md).

## Before you start

* A role with permission to view and manage certificates. Auditors can see the events in **Audit › Console › Certificates** without changing anything.
* Network reachability from the solution to each endpoint, on the port where the certificate is served. The check is a TLS handshake: no account on the server is needed to read a certificate.
* For discovery plans, the assets already registered under **Environment › Assets**.
* Someone subscribed to the alerts. See [Receive the alerts](#receive-the-alerts).

## Steps

### Add a certificate by hand

1. Open **Environment › Certificates**. The **Certificates** tab is the inventory.
2. Click **Add certificate**.
3. Under **Endpoint**, fill in **Name**, **Host** and **Port**. If the server hosts several sites on the same address, fill in **Server name (SNI)** with the name of the site you want.
4. Optionally, link the certificate to an **Asset**. The link is required later if the solution is going to install renewed certificates on that asset.
5. Leave **Monitored** on, and save.

The solution connects to the endpoint straight away and fills in the certificate details.

### Import a certificate that is not reachable

For a certificate that is not served on the network (a client certificate, a file kept for a partner, a certificate behind a load balancer the solution cannot reach), use **Import PEM** in the same form and paste the certificate. An imported certificate is monitored for expiration in the same way, but it is not checked again on the network.

### Find certificates with a discovery plan

1. In **Environment › Certificates**, open the **Discovery** tab.
2. Click **New discovery plan**.
3. Choose the **Assets** or **Nodes** to scan.
4. Under **TLS ports**, keep or change the ports scanned on each asset. The default list is 443, 8443, 9443, 636, 993, 995, 465 and 5986.
5. Under **Schedule**, turn on **Periodic run** to repeat the scan, or leave it off to run it only by hand.
6. Save, then click **Run now**.

Each certificate found goes into the inventory, already linked to its asset. A certificate that is found again in a later run is updated, not duplicated.

## What you should see

The inventory shows one card per certificate with its status and the expiration date. The counters at the top show how many certificates are monitored, how many expire in the next 30 days, how many are expired and how many could not be reached.

| Status          | Meaning                                                                      |
| --------------- | ---------------------------------------------------------------------------- |
| **Valid**       | More than 30 days until expiration                                           |
| **Expiring**    | 30 days or less until expiration                                             |
| **Expired**     | The expiration date has passed                                               |
| **Unreachable** | The last check could not complete the TLS handshake. **Last error** says why |
| **Not checked** | The certificate has not been read yet                                        |

After a discovery run, the plan shows a summary: certificates found, how many are new, and the open ports that answered without TLS.

## How to verify it worked

1. Open a certificate and compare the **SHA-256 fingerprint** with the certificate the server actually presents. From any machine that reaches the endpoint:

   ```bash
   openssl s_client -connect host.example.com:443 -servername host.example.com </dev/null 2>/dev/null \
     | openssl x509 -noout -fingerprint -sha256 -enddate
   ```

   The fingerprint and the end date must match what the solution shows.
2. Click **Check now** on the certificate. **Last check** must change to the current time.
3. Open **Audit › Console › Certificates**. The certificate must appear with a **Certificate added** or **Found by discovery** event.

## Receive the alerts

The daily check sends an expiration alert when a certificate crosses **30, 15 and 7 days** before expiration, and again on the day it expires. Each threshold is sent once, not every day.

The alerts are notifications of the type **Certificate expiring**, in the **Certificates** category. Set who receives them under **System settings › Notifications › Subscription**, with **Edit recipient**. A message type with no recipient is silent.

Every alert is also recorded as an **Expiration alert** event in the audit trail, and goes to your SIEM if syslog forwarding is configured.

## What the daily check detects

The check compares what the server presents with what is in the inventory, so it also records changes nobody announced:

* **Certificate replaced on the server**: the server now presents a different certificate. The event shows the old and the new fingerprint and expiration date.
* **Status changed**: for example, from **Valid** to **Expiring**, or to **Unreachable** when the service stops answering.

## Common errors

| Symptom                                                                     | Cause                                                            | Fix                                                                                            |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| Status **Unreachable**, **Last error** says connection refused or timed out | The solution cannot reach the port, or nothing listens on it     | Check the firewall between the solution and the endpoint, and the port number                  |
| The certificate shown belongs to another site                               | The server hosts several sites and answered with the default one | Fill in **Server name (SNI)** with the name of the site                                        |
| A discovery plan finds nothing on an asset that serves HTTPS                | The service listens on a port that is not in **TLS ports**       | Add the port to the plan and run it again                                                      |
| The plan lists open ports without TLS                                       | Those ports answered, but not with TLS                           | Nothing to fix if the service is not meant to use TLS. Otherwise remove the port from the plan |
| No alert reaches anyone                                                     | The **Certificate expiring** message type has no recipient       | Set the recipient under **System settings › Notifications › Subscription**                     |

## Field reference

| Field                         | What it does                                                                     | Default                                   |
| ----------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------- |
| Name                          | Identifies the certificate in the inventory                                      | —                                         |
| Host                          | Address of the server that presents the certificate                              | —                                         |
| Port                          | TLS port                                                                         | 443                                       |
| Server name (SNI)             | Name sent in the TLS handshake, for servers with several sites on one address    | Empty: the host is used                   |
| Asset                         | The asset where the certificate is installed. Needed for renewal with deployment | Empty                                     |
| Monitored                     | Includes the certificate in the daily check and in the alerts                    | On                                        |
| TLS ports (discovery plan)    | Ports scanned on each asset of the plan                                          | 443, 8443, 9443, 636, 993, 995, 465, 5986 |
| Periodic run (discovery plan) | Repeats the scan on a schedule                                                   | Off                                       |

## Related pages

* [Renew and deploy certificates](https://wiki.datadike.com/pam/administration/certificates/renewal.md)
* [Connect an ACME certificate authority](https://wiki.datadike.com/pam/administration/certificates/acme-accounts.md)
* [Certificate and PGP key audit](https://wiki.datadike.com/pam/administration/audit/certificate-and-key-audit.md)
* [Syslog and SIEM](https://wiki.datadike.com/pam/administration/integrations/syslog-and-siem.md)
* [Certificates and HTTPS](https://wiki.datadike.com/pam/deploy-operate/certificates.md): the certificate of the solution's own console
