title: Extract certificate from a PKCS7 signature in php
body: <p>I need to extract the user certificate from a pkcs7 signature file. I can do it via the command line using the following:</p>
  
  <pre><code>openssl pkcs7 -in somesign.pks7 -inform PEM -print_certs
  </code></pre>
  
  <p>This will give me the entire certificate chain and I can process the resulting file to extract what I want.</p>
  
  <p>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).</p>