diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-03 16:49:19 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-10-03 23:59:08 +0200 |
commit | 753117fed043ac3200093c2dc28161ebce2cd04b (patch) | |
tree | 47df02fa6d732877ccf97ea4562e47506ab91e58 /plugin | |
parent | f67e050430d6d7e577a025e7bf0488bee0a8e450 (diff) | |
download | mariadb-git-753117fed043ac3200093c2dc28161ebce2cd04b.tar.gz |
AWS KMS plugin : more detailed message when API calls fail.
Output API function name, exception name, exception text
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/aws_key_management/aws_key_management_plugin.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc index 60ca6fd1ff3..2c89010c5a7 100644 --- a/plugin/aws_key_management/aws_key_management_plugin.cc +++ b/plugin/aws_key_management/aws_key_management_plugin.cc @@ -106,6 +106,14 @@ static std::mutex mtx; static Aws::KMS::KMSClient *client; +static void print_kms_error(const char *func, const Aws::Client::AWSError<Aws::KMS::KMSErrors>& err) +{ + my_printf_error(ER_UNKNOWN_ERROR, + "AWS KMS plugin : KMS Client API '%s' failed : %s - %s", + ME_ERROR_LOG, + func, err.GetExceptionName().c_str(), err.GetMessage().c_str()); +} + #if WITH_AWS_MOCK /* Mock routines to test plugin without actual AWS KMS interaction @@ -127,7 +135,7 @@ static int mock_generate_encrypted_key(Aws::Utils::ByteBuffer *result) } -static int mock_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +static int mock_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output) { /* We do not encrypt or decrypt in mock mode.*/ *output = input; @@ -401,14 +409,14 @@ static unsigned int get_latest_key_version_nolock(unsigned int key_id) } /* Decrypt Byte buffer with AWS. */ -static int aws_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +static int aws_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output) { DecryptRequest request; request.SetCiphertextBlob(input); DecryptOutcome outcome = client->Decrypt(request); if (!outcome.IsSuccess()) { - *errmsg = outcome.GetError().GetMessage(); + print_kms_error("Decrypt", outcome.GetError()); return -1; } *output= outcome.GetResult().GetPlaintext(); @@ -416,13 +424,13 @@ static int aws_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* out } -static int decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +static int decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output) { #if WITH_AWS_MOCK if(mock) - return mock_decrypt(input,output, errmsg); + return mock_decrypt(input,output); #endif - return aws_decrypt(input, output, errmsg); + return aws_decrypt(input, output); } /* @@ -452,12 +460,9 @@ static int read_and_decrypt_key(const char *path, KEY_INFO *info) Aws::Utils::ByteBuffer input((unsigned char *)contents.data(), pos); Aws::Utils::ByteBuffer plaintext; - Aws::String errmsg; - if (decrypt(input, &plaintext, &errmsg)) + if (decrypt(input, &plaintext)) { - my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Decrypt failed for %s : %s", ME_ERROR_LOG, path, - errmsg.c_str()); return -1; } @@ -491,9 +496,7 @@ int aws_generate_encrypted_key(Aws::Utils::ByteBuffer *result) outcome= client->GenerateDataKeyWithoutPlaintext(request); if (!outcome.IsSuccess()) { - my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin : GenerateDataKeyWithoutPlaintext failed : %s - %s", ME_ERROR_LOG, - outcome.GetError().GetExceptionName().c_str(), - outcome.GetError().GetMessage().c_str()); + print_kms_error("GenerateDataKeyWithoutPlaintext", outcome.GetError()); return(-1); } *result = outcome.GetResult().GetCiphertextBlob(); |