Skip to content

st2api encrypt of £ (and other utf-8 chars) fails with python stacktrace  #4513

Closed
@dswebbthg

Description

@dswebbthg
SUMMARY

Provide a quick summary of your bug or feature request.

ISSUE TYPE

Pick one below and delete the rest:

  • Bug Report
STACKSTORM VERSION

Paste the output of st2 --version:
root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 --version
st2 3.0dev (9577ff9), on Python 3.6.7

OS / ENVIRONMENT / INSTALL METHOD

kubernetes using ubuntu 18.04 using helm

STEPS TO REPRODUCE

root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 key set --scope=system --encrypt test '£'
ERROR: 400 Client Error: Bad Request
MESSAGE: The length of the provided data is not a multiple of the block length. for url: http://stackstorm-ha-st2api:9101/keys/test

During handling of the above exception, another exception occurred:

error log from the st2api container

2019-01-23 16:06:14,301 ERROR [-] Failed to call controller function "put" for operation "st2api.controllers.v1.keyvalue:key_value_pair_controller.put": The length of the provided data is not a multiple of the block length.
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2api/controllers/v1/keyvalue.py", line 301, in put
kvp_db = KeyValuePairAPI.to_model(kvp)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/models/api/keyvalue.py", line 175, in to_model
value = symmetric_encrypt(KeyValuePairAPI.crypto_key, value)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 186, in symmetric_encrypt
return cryptography_symmetric_encrypt(encrypt_key=encrypt_key, plaintext=plaintext)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 237, in cryptography_symmetric_encrypt
ciphertext_bytes = encryptor.update(data) + encryptor.finalize()
File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 159, in finalize
data = self._ctx.finalize()
File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 173, in finalize
"The length of the provided data is not a multiple of "
ValueError: The length of the provided data is not a multiple of the block length.

EXPECTED RESULTS

we should be able to encrypt the £ sign

ACTUAL RESULTS

http 400 and a python stacktrace on the api

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions