I installed SignServer and configured CMSSigner, using the default configuration from doc/sample-configs/qs_cmssigner_configuration.properties. But I cannot verify that the signatures actually match - it looks like the signserver is signing something different from my data(?) This is how I'm trying to verify the signature:
Create a test data file:
$ echo -n 'Hello' > data.txt
Upload data.txt to the web interface of the signserver; the latter replies with data.txt.p7s.
extract the signing certificate from the response:
$ openssl pkcs7 -in data.txt.p7s -inform DER -text -print_certs
The response contains a root CA certificate and an intermediate certificate.
Copy-paste the latter into intermediate-cert.pem and extract the public key:
Why not just use the OpenSSL command to verify the signature and output the signed content like this:
$ openssl cms -verify -inform der -CAfile root.pem -in data.txt.p7s -out content.txt
Verification successful
$ cat content.txt
Hello
Cheers,
Markus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have figured out the source of my signature mismatch. Really, in the file returned by signserver, it is not just the provided data what is signed. Instead, signserver signs the data together with "attributes", which include contentType and signingTime.
Those who wish to manually extract the signature and verify it can do the following:
see what attributes have been signed:
$ openssl cms -in data.p7s -inform der -noout -cmsout -print
Look for signedAttrs. They contain three objects: contentType, signingTime and messageDigest.
in asn1parse output, find the corresponding block and note its size (including header, i.e. 93 + 2 = 95 bytes in this example) and offset (2768):
I installed SignServer and configured CMSSigner, using the default configuration from
doc/sample-configs/qs_cmssigner_configuration.properties
. But I cannot verify that the signatures actually match - it looks like the signserver is signing something different from my data(?) This is how I'm trying to verify the signature:data.txt
to the web interface of the signserver; the latter replies withdata.txt.p7s
.The response contains a root CA certificate and an intermediate certificate.
intermediate-cert.pem
and extract the public key:We see lines:
this is sha1sum('Hello'). I expect this to be the data which is signed... but I do not see that. The RSA signature is here:
Now, looking at what we got:
The hash is not equal to sha1sum('Hello').
Looks like the signserver has signed something else - correct?
Last edit: Konstantin Shemyak 2014-07-03
Why not just use the OpenSSL command to verify the signature and output the signed content like this:
$ openssl cms -verify -inform der -CAfile root.pem -in data.txt.p7s -out content.txt
Verification successful
$ cat content.txt
Hello
Cheers,
Markus
I have figured out the source of my signature mismatch. Really, in the file returned by signserver, it is not just the provided data what is signed. Instead, signserver signs the data together with "attributes", which include
contentType
and signingTime.Those who wish to manually extract the signature and verify it can do the following:
Look for
signedAttrs
. They contain three objects:contentType
,signingTime
andmessageDigest
.asn1parse
output, find the corresponding block and note its size (including header, i.e. 93 + 2 = 95 bytes in this example) and offset (2768):0xa0
to0x31
according to RFC5652, section 5.4.SHA1 sum of the resulting file matches the
OCTET STRING
from