In my PHP script I have a variable $pkcs7_bin
that I would like to transform through openssl
.
Assuming I have my input in a file, I could do this with bash:
cat in.pkcs7 | openssl pkcs7 -inform DER > out.pkcs7
I would like to do the same in PHP such as:
$exit_status execute('openssl pkc7 -inform DER', $pkcs7_bin, $pkcs7_out);
Of course I do not want to use intermediate files.
Is this a simple way to do it?
Currently I have written this:
function execute($process, $stdin, &$stdout)
{
ob_start();
$handle = popen($process, 'w');
$write = fwrite($handle, $stdin)
&$stdout = ob_get_clean();
pclose($handle);
}
But I realized that what the output flushed on my screen is not captured by ob_start
:(