Encrypt SMTP password at rest with AES-256-GCM

This commit is contained in:
Pontoporeia
2026-05-08 12:48:27 +02:00
parent 95fcbc919a
commit 7e35bba530
6 changed files with 184 additions and 16 deletions

View File

@@ -72,6 +72,11 @@ class SmtpRelay
);
$row = $stmt->fetch();
if ($row) {
require_once __DIR__ . '/Crypto.php';
$row['password'] = Crypto::decrypt($row['password']);
}
return $row ?: [
'host' => '',
'port' => 587,
@@ -124,12 +129,13 @@ class SmtpRelay
WHERE id = 1'
);
require_once __DIR__ . '/Crypto.php';
$stmt->execute([
':host' => trim($merged['host']),
':port' => $port,
':encryption' => $encryption,
':username' => trim($merged['username']),
':password' => $merged['password'],
':password' => Crypto::encrypt($merged['password']),
':from_email' => trim($merged['from_email']),
':from_name' => trim($merged['from_name']),
':notify_email' => trim($merged['notify_email'] ?? ''),