您现在的位置是:首页 > 文章详情

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

日期:2019-10-12点击:378

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 官方文档中的“签名和加密消息”文章,以了解有关此功能的更多信息。

原文链接:https://www.oschina.net/news/110518/new-in-symfony-4-4-signing-and-encrypting-email-messages
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章