Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">18.3.0</button>

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/linux/current/docs/troubleshoot-omni-tde.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/linux/18.4.0/docs/troubleshoot-omni-tde.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/linux/18.3.0/docs/troubleshoot-omni-tde.md.txt)

<br />

This page describes how to troubleshoot
[transparent data encryption (TDE)](https://docs.cloud.google.com/alloydb/omni/linux/18.3.0/docs/transparent-data-encryption-omni.md.txt)
issues in AlloyDB Omni.

## Retrieve troubleshooting logs

To troubleshoot TDE issues, you can collect logs depending on your
deployment type.

Collect the systemd logs for the AlloyDB Omni service and filter for TDE-related messages:

```
sudo journalctl -u alloydbomni18 | grep "TDE"
```

The logs might contain entries like the following:

- `TDE: TdeContext initialization failed`
- `TDE: Vault server unreachable`
- `TDE: Certificate expired`

## Error scenarios

This section describes common TDE error scenarios and provides suggested fixes.

### JWT errors

If you see HashiCorp Vault authentication or initialization failures in the
collected logs, they are often related to JSON Web Token (JWT) issues.

#### Description

You might see errors like the following:

| Error | Description | Reason |
|---|---|---|
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 3, error message: JWT cannot be empty` | JWT not found or empty | The JWT token is missing or empty. |
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 3, error message: Invalid JWT format. Expected JWS compact serialization (three dot-separated segments: header, payload, and signature) with base64url encoded values.` | Malformed JWT format | The JWT token is not in the correct JWS compact serialization format. |
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 3, error message: Vault request failed with HTTP code: 400, Vault errors: ["error validating token: invalid expiration time (exp) claim: token is expired"]` | Expired JWT | The JWT token has expired. |
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 3, error message: Vault request failed with HTTP code: 400, Vault errors: ["error validating token: error verifying token signature: failed to verify id token signature"]` | Invalid JWT signature | The Vault server couldn't verify the signature of the JWT token. |
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 9, error message: Failed to get Vault configuration parameter 'VAULT_JWT'` | Permission issue | AlloyDB Omni lacks permission to read the JWT token file, or the `VAULT_JWT` environment variable is not set. |

#### Recommended fix

To resolve JWT issues:

1. Retrieve the active JWT:

   Verify that the JWT token path is defined in your environment or service configuration, for example, in `override.conf`:

   ```
   cat PATH_TO_JWT_FILE
   ```
2. Examine JWT structure: make sure that the token is valid and conforms to
   the JWT compact serialization format.

3. Verify token state: make sure that the token is active and has not
   expired.

### KMS URL errors

If the database fails to initialize or boot, it might be due to a
misconfigured Key Management Service (KMS) Key Encryption Key (KEK) URL.

#### Description

You might see errors like the following:

| Error | Description | Reason |
|---|---|---|
| `TDE: Failed to register Key Store with URL: KMS_URL, error code: 12, error message: Unsupported key store type` | Unsupported key store type | Occurs when the KEK URL protocol is not `vault`. For example, using `http://` or `https://` instead of `vault://`, or omitting the scheme entirely. |
| `TDE: Failed to register Key Store with URL: KMS_URL, error code: 3, error message: Invalid Vault address format. Expected hostname or hostname:port` | Invalid Vault address format | Occurs when the Vault address part of the URL is incorrectly formatted. For example, if it includes the protocol scheme again, such as `vault://https://vault.example.com:8200/...`. |
| `TDE: Failed to read KEK, error code: 3, error message: Invalid key path format. Must start with '/', not end with '/', and contain only valid characters` | Invalid key path format | Occurs when the path part of the Vault URL is malformed. The path must start with a forward slash `/` and must not end with a trailing slash. |
| `TDE: Failed to register Key Store with URL: KMS_URL, error code: 13, error message: curl_easy_perform() failed: Could not resolve hostname` | Hostname resolution failure | Occurs when the Vault hostname in the KEK URL can't be resolved. This can happen if the URL is malformed (for example, `vault://https:`) or if there is a DNS configuration issue. |

#### Recommended fix

- Verify KEK URL scheme: make sure that the URL starts with `vault://`. Don't use `https://` as the prefix.
  - Correct: `vault://vault.example.com:8200/v1/secret/data/key`
  - Incorrect: `https://vault.example.com:8200/v1/secret/data/key`
- Check address format: make sure that the host and port are correctly specified immediately after the `vault://` prefix.
- Verify path formatting: make sure that the path starts with `/` and doesn't have a trailing slash (for example, use `/v1/secret/data/key`, not `/v1/secret/data/key/`).
- Verify host resolution: make sure that the Vault hostname specified in the URL is correct and that it can be resolved from within the database server.

### KEK not base64-encoded

If the KEK stored in HashiCorp Vault is not correctly base64-encoded,
AlloyDB Omni fails to decode it upon retrieval. This prevents
it from unwrapping the local Data Encryption Keys (DEKs) and causes a boot
failure.

#### Description

You might see errors like the following in the database diagnostic logs
(`postgresql.log`):

| Error | Description | Reason |
|---|---|---|
| `TDE: Failed to read KEK, error code: 13, error message: Error decoding base64 key string` | Error decoding base64 key string | Occurs when the key manager attempts to decode the retrieved secret from Vault using Base64, but the string is not valid Base64. |

#### Recommended fix

- Retrieve KEK value: retrieve and inspect the KEK value directly from HashiCorp Vault.
- Update value in Vault: make sure that the KEK stored in Vault is base64-encoded. If it is stored as raw binary or plain text, update the value in Vault with its base64-encoded equivalent.
  1. Convert the raw key to Base64:

     ```
     echo -n "RAW_KEY" | base64
     ```
  2. Update the secret in HashiCorp Vault to the generated base64-encoded string.

### KEK version missing in Vault

The KEK version missing in Vault error occurs when
AlloyDB Omni attempts to unwrap local DEKs using a specific
historical version of the KEK, but that version is deleted, destroyed, or
missing in HashiCorp Vault. This is most common during backup restore
operations or standby replica initialization.

#### Description

You might see errors like the following in the database diagnostic logs
(`postgresql.log`):

| Error | Description | Reason |
|---|---|---|
| `TDE: Failed to read KEK, error code: 5, error message: Vault request failed with HTTP code: 404, Response body: {... "destroyed":true, "version":4 ...}` | Key version destroyed | The requested KEK version is permanently destroyed in Vault. |

#### Recommended fix

- Verify KEK version in Vault: make sure that the requested KEK version is present and active (not deleted or destroyed) in HashiCorp Vault.
- Restore missing KEK version: restore or undelete the requested KEK version in Vault if it has been deleted but not destroyed.
- Handle destroyed keys: if the requested key version is permanently destroyed in Vault, the data or backup encrypted under that version is permanently unrecoverable.

### Bad or missing TLS or SSL certificates

The bad or missing TLS or SSL certificate error occurs when
AlloyDB Omni can't establish a secure TLS connection to
HashiCorp Vault because certificates are missing, expired, untrusted, or
misconfigured.

#### Description

You might see errors like the following in the database diagnostic logs
(`postgresql.log`):

| Error | Description | Reason |
|---|---|---|
| `TDE: Failed to read KEK, error code: 13, error message: curl_easy_perform() failed: SSL peer certificate or SSH remote key was not OK` Or `TDE: Failed to read KEK, error code: 13, error message: curl_easy_perform() failed: Peer certificate cannot be authenticated with given CA certificates` | Vault server certificate verification failed | The Vault server's certificate can't be verified using the provided CA certificate. |
| `TDE: Failed to register Key Store with URL: VAULT_URL, error code: 13, error message: curl_easy_perform() failed: Problem with the local SSL certificate` | Local SSL certificate problem | Occurs if a client certificate is required and has issues. |

#### Recommended fix

To resolve TLS verification issues, make sure that the correct certificates
are supplied, mounted, and readable by the `postgres` user.

Linux expects certificates to be supplied at the path specified in the `VAULT_CERT_PATH` environment variable.

1. Confirm that `VAULT_CERT_PATH` is set correctly in your environment or service override:

   ```
   systemctl show alloydbomni18 -p Environment
   ```
2. Check that the certificate files exist and are readable by the
   `postgres` user:

   ```
   ls -la VAULT_CERT_PATH
   ```

   Make sure that the `ca.crt`, `tls.crt`, and
   `tls.key` filenames are present and that they have read permissions for the `postgres` user.