@@ -1532,7 +1532,7 @@ encrypter that automatically applies to all outgoing messages:
1532
1532
framework :
1533
1533
mailer :
1534
1534
smime_encrypter :
1535
- certificate : ' %kernel.project_dir%/var/certificates/smime.crt '
1535
+ repository : app.my_smime_encrypter
1536
1536
1537
1537
.. code-block :: xml
1538
1538
@@ -1549,7 +1549,7 @@ encrypter that automatically applies to all outgoing messages:
1549
1549
<framework : config >
1550
1550
<framework : mailer >
1551
1551
<framework : smime-encrypter >
1552
- <framework : certificate >%kernel.project_dir%/var/certificates/smime.crt </framework : certificate >
1552
+ <framework : repository >app.my_smime_encrypter </framework : repository >
1553
1553
</framework : smime-encrypter >
1554
1554
</framework : mailer >
1555
1555
</framework : config >
@@ -1563,10 +1563,35 @@ encrypter that automatically applies to all outgoing messages:
1563
1563
return static function (FrameworkConfig $framework): void {
1564
1564
$mailer = $framework->mailer();
1565
1565
$mailer->smimeEncrypter()
1566
- ->certificate('%kernel.project_dir%/var/certificates/smime.crt ')
1566
+ ->repository('app.my_smime_encrypter ')
1567
1567
;
1568
1568
};
1569
1569
1570
+ The ``repository `` option must be a service ID that implements
1571
+ :class: `Symfony\\ Component\\ Mailer\\ EventListener\\ SmimeCertificateRepositoryInterface `::
1572
+
1573
+ namespace App\Security;
1574
+
1575
+ use Symfony\Component\DependencyInjection\Attribute\Autowire;
1576
+ use Symfony\Component\Mailer\EventListener\SmimeCertificateRepositoryInterface;
1577
+
1578
+ class LocalFileCertificateRepository implements SmimeCertificateRepositoryInterface
1579
+ {
1580
+ public function __construct(
1581
+ #[Autowire(param: 'kernel.project_dir')]
1582
+ private readonly string $projectDir
1583
+ ){}
1584
+
1585
+ public function findCertificatePathFor(string $email): ?string
1586
+ {
1587
+ $hash = hash('sha256', strtolower(trim($email)));
1588
+ $path = sprintf('%s/storage/%s.crt', $this->projectDir, $hash);
1589
+
1590
+ return file_exists($path) ? $path : null;
1591
+ }
1592
+ }
1593
+
1594
+
1570
1595
.. versionadded :: 7.3
1571
1596
1572
1597
Global message encryption configuration was introduced in Symfony 7.3.
0 commit comments