Fix migration to non-empty secret

Add a fallback for empty keys

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-12-05 11:28:52 +01:00
parent 4196bf81e6
commit 754cb58b12
2 changed files with 8 additions and 2 deletions

View file

@ -60,7 +60,10 @@ class RSA extends AuthMechanism {
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
$auth->setPassword('');
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
}
}
$storage->setBackendOption('public_key_auth', $auth);
}

View file

@ -58,7 +58,10 @@ class RSAPrivateKey extends AuthMechanism {
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
$auth->setPassword('');
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
}
}
$storage->setBackendOption('public_key_auth', $auth);
}