From dccbfa06bae1544dd0b4a673af94d33842c62361 Mon Sep 17 00:00:00 2001 From: Doug Benjamin Date: Wed, 17 Apr 2024 06:32:54 -0500 Subject: [PATCH] Update cleanDN.py Convert from bytes object to string object --- pandaharvester/harvestertest/cleanDN.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandaharvester/harvestertest/cleanDN.py b/pandaharvester/harvestertest/cleanDN.py index 850242a7..5da7f6e6 100644 --- a/pandaharvester/harvestertest/cleanDN.py +++ b/pandaharvester/harvestertest/cleanDN.py @@ -42,6 +42,12 @@ def clean_user_id(id): p = subprocess.Popen(com.split() + [certFile], stdout=subprocess.PIPE) out, err = p.communicate() +# Convert bytes object to string object if needed +try: + out = out.decode("utf-8") +except (UnicodeDecodeError, AttributeError): + pass + out = re.sub("^subject=", "", out) out = out.strip() print(f'DN: "{out}"')