diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-12-06 15:04:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 15:04:25 +0100 |
commit | 5bc2154bf0acf3d49a31ea979f3fe707cf7395b5 (patch) | |
tree | 3d013c0aa9d6d1c60065b21bcaa6708884c3be58 | |
parent | 987b59b006c9a718fae8e5682134d53016abe53b (diff) | |
parent | 1c558d2f1541776bf30a8d79fe42389bd0c8c964 (diff) | |
download | nextcloud-server-5bc2154bf0acf3d49a31ea979f3fe707cf7395b5.tar.gz nextcloud-server-5bc2154bf0acf3d49a31ea979f3fe707cf7395b5.zip |
Merge pull request #35616 from nextcloud/backport/fix/empty-secret-migration-files-external
[stable25] Fix migration to non-empty secret
-rw-r--r-- | apps/files_external/lib/Lib/Auth/PublicKey/RSA.php | 6 | ||||
-rw-r--r-- | apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php | 6 |
2 files changed, 10 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..d45db03b2da 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php @@ -60,7 +60,11 @@ 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'); + // Add fallback routine for a time where secret was not enforced to be exists + $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..7d04aaaf057 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php @@ -58,7 +58,11 @@ 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'); + // Add fallback routine for a time where secret was not enforced to be exists + $auth->setPassword(''); + if (!$auth->loadKey($storage->getBackendOption('private_key'))) { + throw new \RuntimeException('unable to load private key'); + } } $storage->setBackendOption('public_key_auth', $auth); } |