Skip to content

Commit 1c15305

Browse files
committed
fix dkim path
1 parent 3836962 commit 1c15305

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

.dkim/public.key

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
-----BEGIN PUBLIC KEY-----
2-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAva7UBSxlTA1kGKoDjjSp
3-
5dwwLOKmWJJTkMfu3Vlbwd4HxStIr9OQE+EAINdLjOn3qeUZf6Lrh9ZGs1dcCSjg
4-
KN37m1r0zDsWBN8XYI7pqo13SmY8TYYcr4mVpgo951Lmk2JccVO5kpocwxASmRKd
5-
MzOkifhtegxzAYt04IFtQLOK7vyh0DzncWZaxxfb5HtMPRdgTshEiYVHcd+8AXPv
6-
cE4PuidW95vO3hQ+Y/JmSDSnGbo9ys/AVOGaWK/1YUVIWtlCPTjSxOWkMNRrSJbp
7-
RmYgm+5SbHARXFWsbAvYf/Wui/W1NNL3vOK8lphbCVx9GctHwzIqJR4tztriJS1U
8-
rQIDAQAB
2+
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0zYP/x+dz4PjmLcA6DvP
3+
7jx+ClkSg/u86tXbwBB75JG63/PKKw/811GaoUjV8gSn95/59IoYJE4c06imjMTk
4+
zaThWeQ9p1g3vuN0nVInnAXhMMt0ApOoBe+mlDL5+KcJaDa1ddmLO+vEJybgbF9B
5+
03Jj31vdvAuPgiA7UejyhhUp/k5er/0kSqBmyVikSuJkT+NITUn7LJtGEaYr1tvA
6+
h/lyeYTUKDrdWf7r0eyyXSLy7X2jU3nt0kJrcr6pREdyAkPCnsyWFxgBHMSxoFV6
7+
RukkAMzs82x5dt6Fxuu9tQnyJ0Tv0C9kEZ0PmEIF7HU8rla7D0e5GHRC7zElyUGo
8+
9XHnydfpbUerGDz5Vvb4FgWNYegkyaqhrcGDPfl0LpXw7/eRCCiqwptmn2w3GUAq
9+
7GnPoYD/o8tksxoh2Qrq04m0fJG7SsMOkYNI7W0rElyDEIlj7PgOUUPzhZ8Uqbj4
10+
ou0olB6rNthWmRlS9F3XNcBYPljH0VSJiypvj8uRqMzkM0j7yl0IzBzzIc2Yzd5o
11+
sB/T0FwAyqX3ftza2MBXqDNPEpBH/85MtNg1s2yva5yAr6rs3B8sxwewrO39iDuf
12+
6eJ397KWFk9F+74projtHerC0AGu6vieUWHb7bxm66SOAhvXvz86qR5viSsHoMtv
13+
V08WGzuoEEeQAVn2X3QcrSsCAwEAAQ==
914
-----END PUBLIC KEY-----

config/services.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ parameters:
4545
catrobat.upload.temp.path: "resources/tmp/uploads/"
4646
es_host: "%env(ES_HOST)%"
4747
es_port: "%env(ES_PORT)%"
48+
dkim.private.key: "%kernel.project_dir%/.dkim/private.key"
4849

4950
# This can drastically improve DX by reducing the time to load classes
5051
container.dumper.inline_class_loader: true
@@ -77,6 +78,7 @@ services:
7778
$program_finder: '@fos_elastica.finder.app_program'
7879
$user_finder: '@fos_elastica.finder.app_user'
7980
$refresh_token_ttl: '%lexik_jwt_authentication.token_ttl%'
81+
$dkim_private_key_path: "%dkim.private.key%"
8082

8183

8284
# ====================================================================================================================

deploy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
'var/cache',
5353
'var/log',
5454
'var/sessions',
55-
'public/resources'
55+
'public/resources',
5656
]);
5757

5858
// Symfony executable and variable directories

src/System/Mail/MailerAdapter.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ class MailerAdapter
1515
{
1616
protected MailerInterface $mailer;
1717
protected LoggerInterface $logger;
18+
protected string $dkim_private_key_path;
1819

19-
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
20-
{
20+
public function __construct(
21+
MailerInterface $mailer,
22+
LoggerInterface $logger,
23+
string $dkim_private_key_path // bind in services!
24+
) {
2125
$this->mailer = $mailer;
2226
$this->logger = $logger;
27+
$this->dkim_private_key_path = $dkim_private_key_path;
2328
}
2429

2530
public function send(string $to, string $subject, string $template, array $context = []): void
@@ -43,12 +48,10 @@ protected function buildEmail(string $to, string $subject, string $template, arr
4348
protected function signEmail(Message $email): Message
4449
{
4550
try {
46-
$signer = new DkimSigner('.dkim/private.key', 'catrob.at', 'sf');
47-
48-
return $signer->sign($email);
51+
return (new DkimSigner($this->dkim_private_key_path, 'catrob.at', 'sf'))->sign($email);
4952
} catch (InvalidArgumentException $e) {
5053
if ('prod' === $_ENV['APP_ENV']) {
51-
$this->logger->error('Private dkim key is missing: '.$e->getMessage());
54+
$this->logger->error("Private dkim key is missing ({$this->dkim_private_key_path}): ".$e->getMessage());
5255
}
5356

5457
return $email;

0 commit comments

Comments
 (0)