question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kms#decrypt throws 'utf8' codec error

See original GitHub issue

kms#decrypt throws this error every time:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xf2 in position 2: invalid continuation byte

Repro steps:

import boto3
kms = boto3.client('kms')
result = kms.encrypt(KeyId='some_key_id_redacted',Plaintext='my name is bob')
kms.decrypt(CiphertextBlob=result['CiphertextBlob'])

May be related to this issue

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jstnblaucommented, Dec 4, 2014

The workaround worked for me, but I had to base64 encode the Plaintext as well.

encrypted=kms.encrypt(KeyId='', Plaintext='Test')
decrypted=kms.decrypt(CiphertextBlob=base64.b64encode(encrypted['CiphertextBlob']).decode('utf-8'))
base64.b64encode(decrypted['Plaintext']).decode('utf-8')
0reactions
danielgtaylorcommented, Dec 9, 2014

Released in version 0.0.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 'UnicodeDecodeError: 'utf-8' codec can't decode byte ...
In Python 2, "" is a byte array, but in Python 3 it's a unicode string. Both cipher.encrypt and cipher.decrypt expect byte arrays....
Read more >
Encryption and Decryption using AWS KMS Customer ...
AWS KMS is a service that creates and manages data encryption keys, and controls their usage across different AWS services.
Read more >
Resolve the AWS KMS decrypt error ...
I tried to decrypt environment variables using AWS Lambda encryption helpers and received the error "InvalidCiphertextException". All AWS ...
Read more >
Decrypt with a symmetric key | Cloud KMS Documentation
Decrypt the ciphertext by using the symmetric key.
Read more >
Access denied when uploading to KMS-encrypted Amazon S3 ...
Why am I getting an Access Denied error message when I upload files to my Amazon S3 bucket that has AWS KMS default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found