title: Sign a file and verify with OpenSSL
body: <p>I've some difficulties to understand signature and verification process with openSSL.</p>
  
  <p>I have a small hierarchy of certificate : root cert => sub cert => end entity cert.
  I want to have a code signing certificate from the end entity CA, and thus created a key-pair and requested a CSR : </p>
  
  <pre><code>openssl genrsa -out key.pem
  ...
  openssl genrsa -pubout -in key.pem -out key.pub.pem
  ...
  openssl req -new -sha256 -key key.pem -out id.csr
  ...
  </code></pre>
  
  <p>I send my CSR and recieve the code signing certificat, stored in cert.pem.
  My understanding is that this certificate is only used for verification purpose (verify signature), and my code should be signed with the private key (key.pem) :</p>
  
  <pre><code>openssl dgst -sha256 -sign key.pem -out program.sign program
  </code></pre>
  
  <p>Thus, i've program.sign which is signed with key.pem. Then, I need to verify this signature, considering that i've 4 certificate for the path validation : root.pem, sub.pem, end.pem, cert.pem.</p>
  
  <p>How can I ask openssl to verify the signature with multiple certificate in the chain to check ?</p>
  
  <p>I tried this, but of course it don't work because I only specify the code signing certificate, without the rest of the chain :</p>
  
  <pre><code>openssl dgst -sha256 -verify program -signature program.sign cert.pem
  undable to load key file
  </code></pre>
  
  <p>Am I missing something ?</p>
  
  <p>Thank you very much.</p>