1
I issued the following commands to create a signature for a file (Linux kernel) :
openssl req -newkey rsa -keyout codesign.key -out codesign.req
openssl ca -config ca.cnf -extensions codesigning -in codesign.req -out codesign.crt
openssl cms -sign -binary -noattr -in vmlinuz -signer codesign.crt -inkey codesign.key -certfile ca.crt -outform DER -out vmlinuz.sig
The ca.cnf
file is for my own private CA infrastructure and it has digitalSignature key usage extension and the codeSigning extended key usage extension enabled.
Ca.cnf format:
[ ca ]
default_ca = ca_default
[ ca_default ]
certificate = ca.crt
private_key = ca.key
serial = ca.srl
database = ca.idx
new_certs_dir = /home/apoorv/projects/signed
default_md = default
policy = policy_anything
preserve = yes
default_days = 90
unique_subject = no
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
[ cross ]
basicConstraints = critical,CA:true
keyUsage = critical,cRLSign,keyCertSign
[ codesigning ]
keyUsage = digitalSignature
extendedKeyUsage = codeSigning
Command : openssl cms -verify -binary -content vmlinuz -inform DER -in vmlinuz.sig -CAfile ca.crt
Output:
Verification failure 140187569694352:error:2E099064:CMS routines:CMS_SIGNERINFO_VERIFY_CERT:certificate verify error:cms_smime.c:287:Verify error:unsupported certificate purpose
Could you please provide any input ?? Thanks a lot.
I updated my question. Could you please have a look at it ? Thanks Dave :) – entropy – 2016-04-13T19:41:18.713
Thanks a lot @dave_thompson_085 for helping. Adding the purpose -any option solved our problem. – entropy – 2016-04-15T20:11:34.313
@apoorvmunshi you're welcome, but the StackExchange way is to mark accepted and/or vote as discussed at this link rather than 'thanks'.
– dave_thompson_085 – 2016-04-16T08:45:44.950@dave_thompson_085 ...and maybe to upvote too. But if they also upvote... you will remain tenacious without being an unsung hero
:-)
– Hastur – 2018-05-22T21:24:20.463