summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-12-05 11:28:52 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-12-05 11:28:52 +0100
commit754cb58b1259a58f626d47c2193b92c651d3b2d8 (patch)
tree6142902f9aabee1eb491a79cf0a0a92b4bdc27d7
parent4196bf81e653c39d33d25c76652cc78dab8c5e1c (diff)
downloadnextcloud-server-754cb58b1259a58f626d47c2193b92c651d3b2d8.tar.gz
nextcloud-server-754cb58b1259a58f626d47c2193b92c651d3b2d8.zip
Fix migration to non-empty secret
Add a fallback for empty keys Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--apps/files_external/lib/Lib/Auth/PublicKey/RSA.php5
-rw-r--r--apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php5
2 files changed, 8 insertions, 2 deletions
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
index 2d17b4e9698..199fdfcc6d6 100644
--- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
+++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
@@ -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);
}
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
index 886d16965f4..26cf0501eb6 100644
--- a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
+++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
@@ -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);
}