title: Information used to verify PKCS#7 signature in Java
body: <p>I have 2 files : a PKCS#7 signature and a file, which has been signed by this signature. My question is how can I verify this signature properly? Which data exactly should I use and extract from the PKCS7 in order to do that? I've heard that the order of the actions looks like this:</p>
  
  <ol>
  <li>Check whether a certificate out of date or not</li>
  <li>Check whether CA is out out of date or not</li>
  <li>Check whether this public key is still valid</li>
  <li>And perhaps extract the hash value from the attribute in PKCS7 file and check for equality to a hash file, which has been signed</li>
  </ol>
  
  <p>Am I correct? And how can I do it using Bouncy Castle? I've come across with this</p>
  
  <pre><code>CMSSignedData data = new CMSSignedData(bytesArray)
  </code></pre>
  
  <p>But how can I check validality using only one method, if there is? This looks like overcomplicated - I should take every certificate, check it's expire date, writing custom method that does it.. And somehow check that the public key is still valid.. Is it possible to do it easier?</p>