# Keyring file configuration

> Configure a plaintext file keyring for local development and testing.

---

LLMS index: [llms.txt](/llms.txt)

---

> This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/).

> [!NOTE] Editorial correction
> The inspection example now uses the table it creates and the current database key-info function. See [site errata](/docs/tde/upstream/site/errata/).

This setup is intended for development and stores the keys, unencrypted, in a data file you specify.

> [!NOTE]
>  While keyring files may be acceptable for **local** or **testing environments**, proper [KMS providers](/docs/tde/upstream/global-key-provider-configuration/overview/) are the recommended approach for production deployments.

You can configure key providers either at the database level (for development and testing) or at the global level (for production).

The steps below provide an example on how to add a [database-scoped key provider](/docs/tde/upstream/functions/#add-or-modify-local-key-file-providers):

1. Create a database-scoped file key provider (`file-keyring` in this example) in the `/tmp/pg_tde_test_local_keyring.per` file:

    ```sql
    SELECT pg_tde_add_database_key_provider_file(
        'file-keyring',
        '/tmp/pg_tde_test_local_keyring.per'
    );
    ```

2. Create a key (`my_default_key` in this example) inside the newly created `file-keyring` provider:

    ```sql
    SELECT pg_tde_create_key_using_database_key_provider(
        'my_default_key',
        'file-keyring'
    );
    ```

3. Set the key (`my_default_key`) from the key provider (`file-keyring`):

    ```sql
    SELECT pg_tde_set_key_using_database_key_provider(
        'my_default_key',
        'file-keyring'
    );
    ```

    > [!TIP]
    > You can check the current database key information (such as the date and time of creation). Run:
    >
    > ```sql
    > SELECT pg_tde_key_info();
    > ```

4. Now, create a table using [tde_heap](/docs/tde/upstream/index/table-access-method/#how-tdeheap-works-with-pgtde):

    ```sql
    CREATE TABLE customer_table (a INT) USING tde_heap;
    ```

    The newly created table is encrypted with the database key you have set (`my_default_key`).

    > [!TIP]
    > To check if your created table is encrypted with tde_heap, run:
    >
    > ```sql
    > \d+ customer_table
    > ```
    >
    > If `Access method: tde_heap`, then your table is encrypted.
    >
    > > [!DETAILS] Example output
    > >     postgres=# \d+ customer_table
    > >                                         Table "public.customer_table"
    > >     Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description
    > >     --------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
    > >     a      | integer |           |          |         | plain   |             |              |
    > >     Access method: tde_heap

## Further reading {#further-reading}

Next, for production deployments, [configure a global principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) using a proper [KMS provider](/docs/tde/upstream/global-key-provider-configuration/overview/).

Alternatively, you can skip directly to [validating encryption with pg_tde](/docs/tde/upstream/test/) or [configuring WAL encryption](/docs/tde/upstream/wal-encryption/).

You can also review the available `pg_tde` functions in [Functions](/docs/tde/upstream/functions/).

[PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/keyring.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/keyring.md)

---

Backlinks:

- [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/)
- [Documentation errata](/docs/tde/upstream/site/errata/)
