Skip to content

Commit d1f91f5

Browse files
[FrameworkBundle] make SodiumVault report bad decryption key accurately
1 parent cbaa580 commit d1f91f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Secrets/SodiumVault.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ public function reveal(string $name): ?string
115115
return null;
116116
}
117117

118-
return sodium_crypto_box_seal_open(include $file, $this->decryptionKey);
118+
if (false === $value = sodium_crypto_box_seal_open(include $file, $this->decryptionKey)) {
119+
$this->lastMessage = sprintf('Secrets cannot be revealed as the wrong decryption key was provided for "%s".', $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
120+
121+
return null;
122+
}
123+
124+
return $value;
119125
}
120126

121127
public function remove(string $name): bool

0 commit comments

Comments
 (0)