Hi,
I am trying to encrypt a xml to smime format. I am having some problems while creating the encrypted file. This is my code for encrypting the file
$signcert = 'file://'.realpath('cert.public.pem');
$privkey = 'file://'.realpath('cert.private.pem');
$pubkey = 'file://'.realpath('ttt.pem');
openssl_pkcs7_encrypt("Sample1.xml", "smime.xml",$pubkey,$headers,0,1);
$headers =array();
openssl_pkcs7_sign("smime.xml", "smime.p7m", $signcert,array($privkey, "123456"),$headers ,PKCS7_DETACHED );
This is the header that I get in smime.xml
Content-Disposition: attachment; filename="smime.p7m" // I want this file name to be smime.xml and content type:as text/xml to be displayed with the name as Sample1.xml instead of smime.p7m
Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64
I want to add this header.Content-Type: message/rfc822, how can I add this in the above header.
Once this file is generated I sign the file with my private key.Now when I open smime.p7m file the file has encrypted data but it is still readable. I want that file to be exact smime.p7m file which is not readable and the user has to decrypt that file for reading the content of the file. How can I achieve this using openssl_pk7. Thanks in advance.