Skip to content

PG-1419 Validate key provider on creation #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion contrib/pg_tde/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ cache_alloc \
change_access_method \
insert_update_delete \
key_provider \
keyprovider_dependency \
kmip_test \
partition_table \
pg_tde_is_encrypted \
Expand Down
2 changes: 0 additions & 2 deletions contrib/pg_tde/documentation/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ To add a database specific provider:
pg_tde_add_database_key_provider_<TYPE>('provider_name', ... details ...)
```

Note that in these functions do not verify the parameters. For that, see `pg_tde_verify_key`.

### Changing providers

To change a value of a global provider:
Expand Down
3 changes: 3 additions & 0 deletions contrib/pg_tde/expected/key_provider.out
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ SELECT id, provider_name FROM pg_tde_list_all_global_key_providers();
-1 | file-keyring
(1 row)

-- Creating a file key provider fails if we can't open or create the file
SELECT pg_tde_add_database_key_provider_file('will-not-work','/cant-create-file-in-root.per');
ERROR: Failed to open keyring file /cant-create-file-in-root.per: Permission denied
DROP EXTENSION pg_tde;
3 changes: 3 additions & 0 deletions contrib/pg_tde/expected/key_provider_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,7 @@ SELECT id, provider_name FROM pg_tde_list_all_global_key_providers();
-2 | file-keyring
(2 rows)

-- Creating a file key provider fails if we can't open or create the file
SELECT pg_tde_add_database_key_provider_file('will-not-work','/cant-create-file-in-root.per');
ERROR: Failed to open keyring file /cant-create-file-in-root.per: Permission denied
DROP EXTENSION pg_tde;
34 changes: 0 additions & 34 deletions contrib/pg_tde/expected/keyprovider_dependency.out

This file was deleted.

3 changes: 3 additions & 0 deletions contrib/pg_tde/expected/kmip_test.out
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ SELECT pg_tde_verify_key();
(1 row)

DROP TABLE test_enc;
-- Creating provider fails if we can't connect to kmip server
SELECT pg_tde_add_database_key_provider_kmip('will-not-work','127.0.0.1', 61, '/tmp/server_certificate.pem', '/tmp/client_key_jane_doe.pem');
ERROR: SSL error: BIO_do_connect failed
DROP EXTENSION pg_tde;
3 changes: 3 additions & 0 deletions contrib/pg_tde/expected/vault_v2_test.out
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ SELECT pg_tde_verify_key();
(1 row)

DROP TABLE test_enc;
-- Creating provider fails if we can't connect to vault
SELECT pg_tde_add_database_key_provider_vault_v2('will-not-work', :'root_token', 'http://127.0.0.1:61', 'secret', NULL);
ERROR: HTTP(S) request to keyring provider "will-not-work" failed
DROP EXTENSION pg_tde;
1 change: 0 additions & 1 deletion contrib/pg_tde/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ sql_tests = [
'change_access_method',
'insert_update_delete',
'key_provider',
'keyprovider_dependency',
'kmip_test',
'partition_table',
'pg_tde_is_encrypted',
Expand Down
3 changes: 3 additions & 0 deletions contrib/pg_tde/sql/key_provider.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ SELECT id, provider_name FROM pg_tde_list_all_global_key_providers();
SELECT pg_tde_delete_global_key_provider('file-keyring2');
SELECT id, provider_name FROM pg_tde_list_all_global_key_providers();

-- Creating a file key provider fails if we can't open or create the file
SELECT pg_tde_add_database_key_provider_file('will-not-work','/cant-create-file-in-root.per');

DROP EXTENSION pg_tde;
11 changes: 0 additions & 11 deletions contrib/pg_tde/sql/keyprovider_dependency.sql

This file was deleted.

3 changes: 3 additions & 0 deletions contrib/pg_tde/sql/kmip_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ SELECT pg_tde_verify_key();

DROP TABLE test_enc;

-- Creating provider fails if we can't connect to kmip server
SELECT pg_tde_add_database_key_provider_kmip('will-not-work','127.0.0.1', 61, '/tmp/server_certificate.pem', '/tmp/client_key_jane_doe.pem');

DROP EXTENSION pg_tde;
3 changes: 3 additions & 0 deletions contrib/pg_tde/sql/vault_v2_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ SELECT pg_tde_verify_key();

DROP TABLE test_enc;

-- Creating provider fails if we can't connect to vault
SELECT pg_tde_add_database_key_provider_vault_v2('will-not-work', :'root_token', 'http://127.0.0.1:61', 'secret', NULL);

DROP EXTENSION pg_tde;
4 changes: 2 additions & 2 deletions contrib/pg_tde/src/access/pg_tde_xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tdeheap_rmgr_redo(XLogReaderState *record)
}
else if (info == XLOG_TDE_WRITE_KEY_PROVIDER)
{
KeyringProviderXLRecord *xlrec = (KeyringProviderXLRecord *) XLogRecGetData(record);
KeyringProviderRecordInFile *xlrec = (KeyringProviderRecordInFile *) XLogRecGetData(record);

redo_key_provider_info(xlrec);
}
Expand Down Expand Up @@ -109,7 +109,7 @@ tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record)
}
else if (info == XLOG_TDE_WRITE_KEY_PROVIDER)
{
KeyringProviderXLRecord *xlrec = (KeyringProviderXLRecord *) XLogRecGetData(record);
KeyringProviderRecordInFile *xlrec = (KeyringProviderRecordInFile *) XLogRecGetData(record);

appendStringInfo(buf, "db: %u, provider id: %d", xlrec->database_id, xlrec->provider.provider_id);
}
Expand Down
Loading