Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A client error (InvalidCiphertextException) occurred when calling the Decrypt operation:

When I am trying to execute the command:

aws kms decrypt --ciphertext-blob fileb://CPOEncrypted.txt --output text --query Plaintext

I am getting the below error and I am suspecting that ciphertext issue.

A client error (InvalidCiphertextException) occurred when calling the Decrypt operation:
like image 878
Sai Avatar asked Jul 12 '17 16:07

Sai


1 Answers

1. Make sure your aws is configured on pc, AWS Access Key ID and AWS Secret Access Key are set. To configure it - run in console:

$ aws configure

(http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).

2. make sure the file is correct. I had the same issue because some part of BASE64 was missed during copy-paste - so BASE64 code was incorrect. Now it works fine.I use this command for file creation where code is client_secret encoded in Base64 format (letters and numbers of code were randomly changed in example of course):

$echo ZPATMQE/c3o06DQL0FnZn1Q04Ojh8JbKh87gNohFJFvJ8L456JGFFDhtscGHDjOhbnwKDJnUnK5lkjOJHFDkGuyhgouyfk2YFhgfgffftftDTDBtdbItydbtDbtd65Hf654521JHJHFJGSJFAlc3Qhgb4/s3daa435KHGJGjhgf+as54asd54DKUGdasd54asd5DFf+a54faas65454asUHgTm+a | base64 -di > encrypted-file

3. Then I use this command in console to get the final result:

$ echo $(aws kms decrypt --ciphertext-blob fileb://encrypted-file --query Plaintext --output text | base64 -di)
like image 106
Yevhenii Tsybaiev Avatar answered Sep 29 '22 23:09

Yevhenii Tsybaiev