title: How to validate and extract PKCS#7 file content on Windows (C#/C++)
body: <p>With signtool I can create a PKCS#7 file with the following command</p>
  
  <pre><code>signtool sign /p7 &lt;output dir&gt; /p7co 0 /tr &lt;ts server&gt; /td SHA256 /f &lt;pfx file&gt; /p &lt;pass&gt; /a myfile.zip
  </code></pre>
  
  <p>I get a slightly larger file signed file with .p7 appended.
  I can then verify it with</p>
  
  <pre><code>signtool verify /p7 myfile.zip.p7
  </code></pre>
  
  <p>But what is the recommended way to verify the signature with code and then extract the data? The WinVerifyTrustEx function works fine with PE files, but doesn't like P7 files. It returns 2148204800 ("No Signature was present in the subject"). signtool is not redistributable and it doesn't have an option to extract the data.</p>