Symfony 4.4 新功能预览:对电子邮件进行签名和加密

栏目: 软件资讯 · 发布时间: 6年前

内容简介:Symfony 4.4 将于 2019 年 11 月发布。官方发布了关于该系列的第一篇文章,介绍了此 Symfony 版本引入的最重要的新功能。 Symfony 4.3 中引入了新的 Mailer 和 Mime 组件,以取代之前基于 SwiftMailer 的解决方案...

Symfony 4.4 将于 2019 年 11 月发布。官方发布了关于该系列的第一篇文章,介绍了此 Symfony 版本引入的最重要的新功能。

Symfony 4.3 中引入了新的 Mailer 和 Mime 组件,以取代之前基于 SwiftMailer 的解决方案。在 Symfony 4.4 中,开发团队使用新功能对其进行了改进,以允许使用 S/MIME 标准对电子邮件进行签名和加密。

对消息进行签名可以提高其完整性,因为它包括整个电子邮件内容的哈希值的数字签名,从而确保原始内容没有被修改:

use Symfony\Component\Mime\Crypto\SMimeSigner;
use Symfony\Component\Mime\Email;

$email = (new Email())->from('...')->to('...')->html('...');

$signer = new SMimeSigner('/path/to/certificate.crt', '/path/to/certificate-private-key.key');
$signedEmail = $signer->sign($email);
// now use the Mailer to send this $signedEmail instead of the original $email

加密消息可提高其安全性,因为只有包含与用于加密消息的公共密钥相关联的私有密钥,才能读取其内容(包括任何附件):

use Symfony\Component\Mime\Crypto\SMimeEncrypter;
use Symfony\Component\Mime\Email;

$email = (new Email())->from('...')->to('...')->html('...');

$encrypter = new SMimeEncrypter('/path/to/certificate.crt');
$encryptedEmail = $encrypter->encrypt($email);
// now use the Mailer to send this $encryptedEmail instead of the original $email

可查阅 Symfony 官方文档中的“签名和加密消息”文章,以了解有关此功能的更多信息。


以上所述就是小编给大家介绍的《Symfony 4.4 新功能预览:对电子邮件进行签名和加密》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

An Introduction to the Analysis of Algorithms

An Introduction to the Analysis of Algorithms

Robert Sedgewick、Philippe Flajolet / Addison-Wesley Professional / 1995-12-10 / CAD 67.99

This book is a thorough overview of the primary techniques and models used in the mathematical analysis of algorithms. The first half of the book draws upon classical mathematical material from discre......一起来看看 《An Introduction to the Analysis of Algorithms》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具