Symfony 4.4 将于 2019 年 11 月公布。官方发布了有关该系列产品的第一篇文章内容,详细介绍了此 Symfony 版本引入的最重要的新作用。
Symfony 4.3 中引入了新的 Mailer 和 Mime 部件,以替代以前根据 SwiftMailer 的解决方法。在 Symfony 4.4 中,开发设计精英团队应用新作用对其开展了改善,以容许应用 S/MIME 规范对电子邮件开展签字和数据加密。
对信息开展签字能够提升其一致性,因为它包含全部电子邮件內容的hash值的电子签名,进而保证初始內容沒有被改动:
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 官方网文本文档中的“签字和数据加密信息”文章内容,以掌握相关此作用的其他信息。
文章转载自网络,如有侵权,请联系api@1dq.com删除