我不完全理解,并且会非常感谢一些文档或帮助:)
使用PHP我使用ezcomponents Mail对象创建MIME。但我不明白的是:
是否通过使用openssl_pkcs7_sign对原始MIME进行签名来创建S / MIME邮件?或者你是从头创建一个S / MIME并在完成时签名?
当我试图了解正确的做事方式时,请耐心等待。
编辑:找到这段代码来更好地说明我的问题
<?
// Setup mail headers.
$headers = array("To" => "someone@nowhere.net",
"From" => "noone@somewhere.net",
"Subject" => "A signed and encrypted message.");
// Sign the message first
openssl_pkcs7_sign("msg.txt","signed.txt",
"signing_cert.pem",array("private_key.pem",
"password"),array());
// Get the public key certificate.
$pubkey = file_get_contents("cert.pem");
//encrypt the message, now put in the headers.
openssl_pkcs7_encrypt("signed.txt", "enc.txt",
$pubkey,$headers,0,1);
$data = file_get_contents("enc.txt");
// separate header and body, to use with mail function
// unfortunate but required, else we have two sets of headers
// and the email client doesn't decode the attachment
$parts = explode("\n\n", $data, 2);
// send mail (headers in the Headers parameter will override those
// generated for the To & Subject parameters)
mail($mail, $subject, $parts[1], $parts[0]);
?>