diff --git a/authentik/crypto/models.py b/authentik/crypto/models.py index 3b447e66d..afe30e6ee 100644 --- a/authentik/crypto/models.py +++ b/authentik/crypto/models.py @@ -55,11 +55,14 @@ class CertificateKeyPair(CreatedUpdatedModel): def private_key(self) -> Optional[RSAPrivateKey]: """Get python cryptography PrivateKey instance""" if not self._private_key and self._private_key != "": - self._private_key = load_pem_private_key( - str.encode("\n".join([x.strip() for x in self.key_data.split("\n")])), - password=None, - backend=default_backend(), - ) + try: + self._private_key = load_pem_private_key( + str.encode("\n".join([x.strip() for x in self.key_data.split("\n")])), + password=None, + backend=default_backend(), + ) + except ValueError: + return None return self._private_key @property