jsign icon indicating copy to clipboard operation
jsign copied to clipboard

"No signature found"/"No signature was present in the subject" when signing exe

Open markawightman75 opened this issue 4 years ago • 45 comments

Hi,

Firstly - thanks for your amazing work on jsign. It's exactly what we need!

We're trying to sign a Windows exe using a SHA512 key stored in Google KMS and with an EV certificate from GlobalSign, but the digital signature on the exe has the "No signature was present in the subject" message, and verifying with SignTool reports "No signature found".

I'm running jsign from code, having cloned the repo a couple of days ago.

We created a key like this:

gcloud kms keys create focal-point-code-signing-key \
--keyring code-signing-ring \
--location europe-west2 \
--purpose asymmetric-signing \
--protection-level hsm \
--default-algorithm rsa-sign-pss-4096-sha512

gcloud kms keys versions \
get-public-key 1 \
--location europe-west2 \
--keyring code-signing-ring \
--key focal-point-code-signing-key \
--output-file ./focal-point-code-signing-key.pub

and a CSR using https://github.com/mattes/google-cloud-kms-csr, which we used to get our certificate from GlobalSign. The certificate itself has a signature algorithm of sha256WithRSAEncryption but my understanding is that this doesn't need to match the signature algorithm we use to sign the exe?

We're using the following parameters with jsign:

--storetype "GOOGLECLOUD" \
--storepass <token>
--keystore projects/waives-service/locations/europe-west2/keyRings/code-signing-ring
--alias projects/waives-service/locations/europe-west2/keyRings/code-signing-ring/cryptoKeys/focal-point-code-signing-key/cryptoKeyVersions/1
--tsaurl http://timestamp.globalsign.com/tsa/r6advanced1
--tsmode RFC3161
--alg SHA-512
--certfile /home/mark/code/code-signing/focal-point-code-signing-certificate.cer
<file-to-sign.exe>

Do you have any ideas about what could be going on, or suggestions about how we could investigate? We don't currently have a thread to pull on.

Really appreciate all your work, and any suggestions you might have!

Thanks,

Mark

markawightman75 avatar Jun 30 '21 17:06 markawightman75

Here's a screenshot of the exe properties.

image

I'm slightly suspicious of "No signature was present in the subject" also appearing in the certificate information for our certificate:

image

markawightman75 avatar Jun 30 '21 17:06 markawightman75

Thank you for the feedback. Would you be able to sign the wineyes.exe file from the Jsign test resources and send it to [email protected] please? I'll get a look.

ebourg avatar Jun 30 '21 17:06 ebourg

Thanks Emmanuel, much appreciated - I've emailed it to you.

markawightman75 avatar Jun 30 '21 18:06 markawightman75

I looked at the signed file but I fail to see what's wrong. Would you be able to sign it with signtool and see if there is the same error? If it works with signtool a side by side comparison of the two signatures will certainly unveil the cause of the issue. I suggest disabling the timestamping to simplify the comparison.

ebourg avatar Jun 30 '21 23:06 ebourg

Hi Emmanuel. Thanks for looking. Yes, we'll try what you suggest. Are you able to point at any instructions for how to sign with SignTool when our private/public key is in Google KMS? We've failed to find any guide on how to do this!

markawightman75 avatar Jul 01 '21 07:07 markawightman75

Good question, I assume there is a PKCS#11 library somewhere for Google KMS but I haven't found one yet.

ebourg avatar Jul 01 '21 08:07 ebourg

Maybe using this ? https://github.com/nextgens/authenticode-sign-action https://github.com/nextgens/CloudSignTool https://github.com/nextgens/CloudSignTool/releases/download/1.0.0/SignTool.exe

ebourg avatar Jul 01 '21 08:07 ebourg

Thanks, yes I've tried CloudSignTool and am getting the same result. This suggests it isn't a JSign issue, but I'm at a loss to understand where the issue could be. I think I'll have to go back to GlobalSign and see if they have any suggestions.

markawightman75 avatar Jul 01 '21 12:07 markawightman75

There's propably an issue with the certificate then. Let me know if you find out the issue, that may help others in the future.

ebourg avatar Jul 01 '21 12:07 ebourg

Thanks Emmanuel, yes I will.

markawightman75 avatar Jul 01 '21 20:07 markawightman75

@markawightman75 did you ever get this resolved? I am getting the same error with a GlobalSign EV certificate. It seems related to the 4096 key size.

opub avatar Oct 27 '21 21:10 opub

@markawightman75 How did you resolve this problem?

maxpain avatar Nov 23 '21 11:11 maxpain

@markawightman75 I'm having exactly the same issue. Any updates on your side? Did you ever get this resolved?

woohgit avatar Dec 16 '21 02:12 woohgit

@markawightman75 I'm having exactly the same issue. Any updates on your side? Did you ever get this resolved?

I resolved this problem by changing the sequence of certificates in the chain.

maxpain avatar Dec 16 '21 06:12 maxpain

@maxpain In what order?

  1. your cert
  2. their cert (GlobalSign Root CA?)

woohgit avatar Dec 16 '21 07:12 woohgit

@maxpain In what order?

  1. your cert
  2. their cert (GlobalSign?)
image

I got all 3 certificates from GlobalSign.

maxpain avatar Dec 16 '21 07:12 maxpain

Example:

jsign --storetype GOOGLECLOUD \
        --storepass "$(gcloud auth print-access-token)" \
        --keystore projects/codesigning/locations/europe-central2/keyRings/CodeSigning \
        --alias ev4096 \
        --certfile full-chain.pem \
        --tsaurl http://timestamp.globalsign.com/tsa/r6advanced1 \
        --tsmode RFC3161 \
        example_app.exe

maxpain avatar Dec 16 '21 07:12 maxpain

@maxpain Are all certs have 4096 bit length?

woohgit avatar Dec 16 '21 08:12 woohgit

@maxpain Are all certs have 4096 bit length?

I don't know. How to check?

maxpain avatar Dec 16 '21 08:12 maxpain

@maxpain Are all certs have 4096 bit length?

I don't know. How to check?

cat intermediate1.cer | openssl x509 -text -noout

Check the RSA Public-key (XXXX bit) part of the output.

woohgit avatar Dec 16 '21 08:12 woohgit

image

maxpain avatar Dec 16 '21 08:12 maxpain

image

Thanks!

woohgit avatar Dec 16 '21 08:12 woohgit

image

And how did you generate the CSR which was signed by GlobalSign? I assume you're also using Cloud HSM (AWS or Google)

woohgit avatar Dec 16 '21 08:12 woohgit

And how did you generate the CSR which was signed by GlobalSign? I assume you're also using Cloud HSM (AWS or Google)

I used this: https://github.com/mattes/google-cloud-kms-csr

maxpain avatar Dec 16 '21 09:12 maxpain

And how did you generate the CSR which was signed by GlobalSign? I assume you're also using Cloud HSM (AWS or Google)

I used this: https://github.com/mattes/google-cloud-kms-csr

Sorry for the questions but one more last: What kind of keys do you have in HSM. What's the key type / algorithm? I suspect we're using a not properly supported version on Google Cloud KMS HSM

woohgit avatar Dec 16 '21 09:12 woohgit

Screenshot 2021-12-16 at 12 29 55 Screenshot 2021-12-16 at 12 29 59

maxpain avatar Dec 16 '21 09:12 maxpain

Screenshot 2021-12-16 at 12 29 55 Screenshot 2021-12-16 at 12 29 59

Perfect, and what's the algorithm inside if you click on the ev4096 key?

Mine looks like this:

2021-12-16_19-36

woohgit avatar Dec 16 '21 10:12 woohgit

image

maxpain avatar Dec 16 '21 10:12 maxpain

image

Million thanks!

woohgit avatar Dec 16 '21 12:12 woohgit

@maxpain I can verify that it works with 4096 bit RSA key (PKCS#1 v1.5 padding - SHA256 Digest)

But it does not work with Google KMS HSM - 4096 bit RSA key (PSS Padding - SHA265 Digest). Maybe it's related to the original issue.

cc @ebourg @markawightman75

woohgit avatar Dec 16 '21 23:12 woohgit