> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/cdm/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/cennso/cdm/latest/troubleshooting/tls-handshake-failure.md).

# TLS handshake fails

Core Clusters connect to CDM Node on port 6237 over TLS. The handshake fails in two cases. The certificate that CDM Node serves does not match the domain of the Core Cluster, or the Core Cluster does not trust the issuer of the certificate. The Core Cluster cannot join CDM until the handshake succeeds.

## Symptoms

- The log of the Cennso Agent on the Core Cluster contains a TLS error that includes `x509`. Typical messages are `certificate is valid for ..., not ...` for a name mismatch and `certificate signed by unknown authority` for an untrusted issuer.
- The `openssl` check from your workstation reports a verification error. The check connects with the domain that the Core Cluster uses:

  ```bash
  openssl s_client -connect {CDM_DOMAIN}:6237 -servername {CDM_DOMAIN} -verify_hostname {CDM_DOMAIN} </dev/null 2>&1 | grep Verification
  ```

  For a name mismatch, the output is:

  ```text
  Verification error: hostname mismatch
  ```

  For a certificate from an issuer that your workstation does not trust, the output names the verification error. For example, a self-signed certificate gives:

  ```text
  Verification error: self-signed certificate
  ```

## Possible causes

- The certificate does not contain a name that matches the domain. A wildcard name matches exactly one DNS label, so `*.test.example.net` does not match `cdm-node.public.test.example.net`. To list the names in the certificate that CDM Node serves, run:

  ```bash
  openssl s_client -connect {CDM_DOMAIN}:6237 -servername {CDM_DOMAIN} </dev/null 2>/dev/null | openssl x509 -noout -ext subjectAltName
  ```

- The certificate comes from an issuer that is not publicly trusted. To show the issuer, run:

  ```bash
  kubectl -n cennso-system get secret cdm-tls-cert -o jsonpath='{.data.tls\.crt}' | base64 -d | openssl x509 -noout -issuer
  ```

## Solution

To resolve this issue, correct the certificate:

1. If a name is missing, add it to `spec.dnsNames` of the `cdm-tls-cert` Certificate and apply the resource. Add one wildcard for each domain level, for example `*.public.test.example.net`. For the steps, see [Configure the CDM TLS certificate](https://docs.cennso.com/cennso/cdm/latest/guides/configure-cdm-tls-certificate.md#add-a-domain-name-later).

2. If the issuer is not publicly trusted, change `spec.issuerRef` of the Certificate to a `ClusterIssuer` that uses a publicly trusted certificate authority.

3. Wait until CDM Node serves the new certificate. CDM Node 1.7.0 and later restart by themselves. For earlier versions, see [CDM Node serves an old certificate](https://docs.cennso.com/cennso/cdm/latest/troubleshooting/stale-certificate.md).

4. Run the `openssl` check again. The output is `Verification: OK` when the certificate is correct.
