Skip to content
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

A function to get the current master key info. #150

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

codeforall
Copy link
Collaborator

Commit adds tde_master_key_info() function that returns the information about the master key for the database.

select * from tde_master_key_info();

master_key_name | key_provider_name | key_provider_id | master_key_internal_name | master_key_version | key_createion_time

-----------------+-------------------+-----------------+--------------------------+--------------------+-------------------------------

test-master-key | file-two | 1 | test-master-key_1 | 1 | 2024-03-25 18:07:13.131834+05

(1 row)

Commit adds tde_master_key_info() function that returns
the information about the master key for the database.

select * from tde_master_key_info();

 master_key_name | key_provider_name | key_provider_id | master_key_internal_name | master_key_version |      key_createion_time

-----------------+-------------------+-----------------+--------------------------+--------------------+-------------------------------

 test-master-key | file-two          |               1 | test-master-key_1        |                  1 | 2024-03-25 18:07:13.131834+05

(1 row)
Copy link
Collaborator

@dutow dutow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor formatting related comments, but I think we also might have an issue with an unconfigured pg_tde, please add a test about that too

sql/pgtde_is_encrypted.sql Outdated Show resolved Hide resolved
@@ -31,7 +32,7 @@

#define DEFAULT_MASTER_KEY_VERSION 1

typedef struct TdeMasterKeySharedState
typedef struct TdeMasterKeySharedState
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary formatting change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was un-intentional. Thanks for pointing out. Fixed

GenericKeyring *keyring;

/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also inconsistent indentation in this function

@@ -21,6 +21,9 @@ SELECT amname FROM pg_class INNER JOIN pg_am ON pg_am.oid = pg_class.relam WHERE
SELECT pgtde_is_encrypted('test_enc');
SELECT pgtde_is_encrypted('test_norm');

SELECT key_provider_id, key_provider_name, master_key_name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also have a test with the extension enabled, but without anything configured? (no provider / master key added)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in context that cannot accept type record")));

master_key = GetMasterKey();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master_key can be NULL

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetMasterKey() throws an ERROR when it can't return the master key. I have still added a check here.

@codeforall codeforall merged commit 7be28b4 into percona:main Mar 27, 2024
10 checks passed
@codeforall codeforall deleted the mk-info branch March 27, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants