From 72ef87421bd472a0eecf22b24d10277180c7a1f3 Mon Sep 17 00:00:00 2001 From: aapostoliuk Date: Fri, 10 Mar 2023 10:38:18 +0200 Subject: util: T5074: Fixed decoding of certificate value to UTF-8 string Fixed decoding of certificate value returned by vici to UTF-8 string. --- python/vyos/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/vyos/util.py b/python/vyos/util.py index 66ded464d..0593184cc 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -874,12 +874,16 @@ def convert_data(data): Returns: str | list | dict: converted data """ + from base64 import b64encode from collections import OrderedDict if isinstance(data, str): return data if isinstance(data, bytes): - return data.decode() + try: + return data.decode() + except UnicodeDecodeError: + return b64encode(data).decode() if isinstance(data, list): list_tmp = [] for item in data: -- cgit v1.2.3