mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Fix decryption fallback after adding a secret
Signed-off-by: Julius Härtl <jus@bitgrid.net>
(cherry picked from commit a6796b4247)
This commit is contained in:
parent
3ebf7b818b
commit
0f7260de03
1 changed files with 10 additions and 5 deletions
|
|
@ -122,14 +122,19 @@ class Crypto implements ICrypto {
|
|||
* @throws Exception If the decryption failed
|
||||
*/
|
||||
public function decrypt(string $authenticatedCiphertext, string $password = ''): string {
|
||||
if ($password === '') {
|
||||
$password = $this->config->getSystemValue('secret');
|
||||
}
|
||||
$secret = $this->config->getSystemValue('secret');
|
||||
try {
|
||||
if ($password === '') {
|
||||
return $this->decryptWithoutSecret($authenticatedCiphertext, $secret);
|
||||
}
|
||||
return $this->decryptWithoutSecret($authenticatedCiphertext, $password);
|
||||
} catch (Exception $e) {
|
||||
// Retry with empty secret as a fallback for instances where the secret might not have been set by accident
|
||||
return $this->decryptWithoutSecret($authenticatedCiphertext, '');
|
||||
if ($password === '') {
|
||||
// Retry with empty secret as a fallback for instances where the secret might not have been set by accident
|
||||
return $this->decryptWithoutSecret($authenticatedCiphertext, '');
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue