I’m trying to send S/Mime signed and encrypted emails.
I have this code:
// Sign the message first
openssl_pkcs7_sign("inc/admin/email/body.txt","inc/admin/email/body/enc.txt",
"signing_cert.pem",array("private_key.pem",
"test"),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);
My question is which cert is which? If I use the certs I have (is this ok) the files I have are:
- .key
- .csr
- .crt
- and the public .pem.
Which is which?
Generally speaking PEM can be private key, public key and also certificate.
It gepends how did you create/gain certificate.
But in your case, I expect following:
CSR = Certificate signing request, useless for you now
CRT = Certificate
KEY = Private key
PEM = Public key/Certificate