I need to extract the user certificate from a pkcs7 signature file. I can do it via the command line using the following:
openssl pkcs7 -in somesign.pks7 -inform PEM -print_certs
This will give me the entire certificate chain and I can process the resulting file to extract what I want.
Is there any way to do that with the openssl_pkcs7_ commands? I saw that openssl_pkcs7_verify has the $outfilename where the certs would be stored but I don't have the signed message, but it seems the $filename should have both the signature and the message, which is not my case (signature is in a separate file).
I have already using it via
exec()function.But I think, the best choise is to use the structure of SMIME files. You can obtain the structure by analysing the source code of OpenSSL. Finding it maybe tough,but once you find it,you can use it anywhere. OpenSSL GitHub source code is available here