Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Mailer][Mime] Refactor S/MIME encryption handling inSMimeEncryptionListener#20935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletionsmailer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1532,7 +1532,7 @@
framework:
mailer:
smime_encrypter:
certificate: '%kernel.project_dir%/var/certificates/smime.crt'
repository: app.my_smime_encrypter

Check failure on line 1535 in mailer.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] In CheckExceptionOnInvalidReferenceBehaviorPass.php line 116: The service "mailer.smime_encrypter.listener" has a dependency on a non-exi stent service "app.my_smime_encrypter".

.. code-block:: xml

Expand All@@ -1549,7 +1549,7 @@
<framework:config>
<framework:mailer>
<framework:smime-encrypter>
<framework:certificate>%kernel.project_dir%/var/certificates/smime.crt</framework:certificate>
<framework:repository>app.my_smime_encrypter</framework:repository>
</framework:smime-encrypter>
</framework:mailer>
</framework:config>
Expand All@@ -1563,10 +1563,35 @@
return static function (FrameworkConfig $framework): void {
$mailer = $framework->mailer();
$mailer->smimeEncrypter()
->certificate('%kernel.project_dir%/var/certificates/smime.crt')
->repository('app.my_smime_encrypter')
;
};

Check failure on line 1568 in mailer.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] In CheckExceptionOnInvalidReferenceBehaviorPass.php line 116: The service "mailer.smime_encrypter.listener" has a dependency on a non-exi stent service "app.my_smime_encrypter".

The ``repository`` option must be a service ID that implements
:class:`Symfony\\Component\\Mailer\\EventListener\\SmimeCertificateRepositoryInterface`::

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The purpose of the methodSmimeCertificateRepositoryInterface::findCertificatePathFor is to resolve the certificate file path for a given email address, as the S/MIME encrypter expects a valid local file path to the certificate.

namespace App\Security;

use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Mailer\EventListener\SmimeCertificateRepositoryInterface;

class LocalFileCertificateRepository implements SmimeCertificateRepositoryInterface
{
public function __construct(
#[Autowire(param: 'kernel.project_dir')]
private readonly string $projectDir
){}

public function findCertificatePathFor(string $email): ?string
{
$hash = hash('sha256', strtolower(trim($email)));
$path = sprintf('%s/storage/%s.crt', $this->projectDir, $hash);

return file_exists($path) ? $path : null;
}
}


.. versionadded:: 7.3

Global message encryption configuration was introduced in Symfony 7.3.
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp