From c565e69a018317ff46802770a3d78fd13ca44ca1 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Tue, 29 Nov 2022 13:34:22 +0100 Subject: [PATCH] as requested --- core/admin/mailu/schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/admin/mailu/schemas.py b/core/admin/mailu/schemas.py index bae9be16..4a9792ec 100644 --- a/core/admin/mailu/schemas.py +++ b/core/admin/mailu/schemas.py @@ -609,8 +609,8 @@ class DkimKeyField(fields.String): # check key validity try: - serialization.load_pem_private_key(value, password=None) - except crypto.Error as exc: + serialization.load_pem_private_key(bytes(value, "ascii"), password=None) + except (UnicodeEncodeError, ValueError) as exc: raise ValidationError(f'invalid dkim key {bad_key!r}') from exc else: return value