From 0745ab0fdf130322c003cb5574d58b55bd821b90 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 9 Jun 2017 18:57:30 -0400 Subject: [PATCH] Auto-encode unicode if needed If unicode comes in to be crypted and fails, be explicit about utf-8 encoding. --- confluent_server/confluent/config/configmanager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 74a9f949..87816be7 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -261,7 +261,10 @@ def crypt_value(value, neededpad = 16 - (len(value) % 16) pad = chr(neededpad) * neededpad value += pad - cryptval = crypter.encrypt(value) + try: + cryptval = crypter.encrypt(value) + except TypeError: + cryptval = crypter.encrypt(value.encode('utf-8')) hmac = HMAC.new(integritykey, cryptval, SHA256).digest() return iv, cryptval, hmac