I've some difficulties to understand signature and verification process with openSSL.
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 :
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
...
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) :
openssl dgst -sha256 -sign key.pem -out program.sign program
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.
How can I ask openssl to verify the signature with multiple certificate in the chain to check ?
I tried this, but of course it don't work because I only specify the code signing certificate, without the rest of the chain :
openssl dgst -sha256 -verify program -signature program.sign cert.pem
undable to load key file
Am I missing something ?
Thank you very much.