Move self._view_on_starting() outside of loading keys exception

When _view_on_starting is inside the try:except:, any display errors, especially from misconfigured plugins, will trigger the exception and delete RSA keys unnecessarily.
By moving _view_on_starting after the except: clause, only errors during key loading will lead to deleted keys. view errors will silently fail.

Signed-off-by: Sniffleupagus <129890632+Sniffleupagus@users.noreply.github.com>
This commit is contained in:
Sniffleupagus
2024-12-06 11:06:38 -08:00
committed by GitHub
parent 39c38d130b
commit 0c44b02765

View File

@ -50,10 +50,6 @@ class KeyPair(object):
with open(self.fingerprint_path, 'w+t') as fp: with open(self.fingerprint_path, 'w+t') as fp:
fp.write(self.fingerprint) fp.write(self.fingerprint)
# no exception, keys loaded correctly.
self._view.on_starting()
return
except Exception as e: except Exception as e:
# if we're here, loading the keys broke something ... # if we're here, loading the keys broke something ...
logging.exception("error loading keys, maybe corrupted, deleting and regenerating ...") logging.exception("error loading keys, maybe corrupted, deleting and regenerating ...")
@ -63,6 +59,9 @@ class KeyPair(object):
except: except:
pass pass
# no exception, keys loaded correctly.
self._view.on_starting()
return
def sign(self, message): def sign(self, message):
hasher = SHA256.new(message.encode("ascii")) hasher = SHA256.new(message.encode("ascii"))
signer = PKCS1_PSS.new(self.priv_key, saltLen=16) signer = PKCS1_PSS.new(self.priv_key, saltLen=16)