-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] jarsigner + jca reports that entries in certificate chain are invalid #41832
Comments
HI @3millionminds, thank you for filing this issue, I'll pass it along to the team. @saragluna, @rujche Could you take a look when you get a chance? Thanks! |
Hi, @3millionminds Thanks for reaching out. It's weird that when you sign the jar, the signer only has one cert, and the cert is trusted In my understanding, it should be a chain, and only the root cert is trusted. Here is an example: #41303 (comment) Could you please add jarsigner -verify -verbose -certs SIGNED_SignMe..jar Caution: remove private information when upload the log file, just like you did above. |
Hello @rujche, thank you for picking up this issue. Here are the logs: I will try and import the root ca into the local keystore first and then follow the signing&verification process. I will return with the results. |
@rujche if import the DigiCert CA into the local keystore it works on the machine where it is imported in the keystore.
Same thing if I import only our certificate. |
Hi, @3millionminds 1. About importing the DigiCert CA into the local keystore
By saying keytool -import -alias digicertca -keystore $JAVA_HOME/jre/lib/security/cacerts -file DigiCertCA.crt 2. Root CA cert should be added into cacertsTo verify a jar signed by a cert, the cert's root CA cert should be added in to 3. Seems there is only one cert in the cert chain.As mentioned above #41832 (comment), it's weird that in your provided log, the signer only has one cert, is this cert self-signed? it shouldn't be. It should be signed by DigiCert CA. Here is the screenshot of your provided log: In my test case (#41303 (comment)), both sign and verify showed 3 certs in the cert chain. Here are the screenshots of my test case: |
Hi @rujche
After installing the DigiCert CA on the machine where I do the signing, I can verify the jar file, it no longer complains about the certificate chain. But, as mentioned here, when trying to verify the jar on a different machine, the issue returns. I imagine if they had the certificate in their Our usecase is the following: the jars are built, signed, and then packaged into a larger application, which is delivered to the end clients. This software is then deployed on hundreds of computers where, due to security restrictions, it cannot run. Before switching to Azure Key Vault, a local PFX certificate was used for signing. |
Hi, @3millionminds 1. About the cert chain
In my understanding, if it is signed by DigiCert, then the cert chain should have more than one cert. When sign and verify jar file using the cert, it should display all the certs in the cert chain. But your log only show one cert. I'm confused about this. 2. About your use case.
Now I understand your case. Now I'm also confused why it work with the local pfx file but not work with Azure Key Vault method. 3. How to do next step?I suggest you do these things:
If the problem still can not be solved after above steps, please share related log, and let's think about how to do next step. |
Hello @rujche
|
Hi, @3millionminds 1. About DigiCert root CA.
In your screenshot, I see the root cert name (CN=digicert_trusted_root_g4). keytool -list -keystore "C:\Program Files\Microsoft\jdk-17.0.11.9-hotspot\lib\security\cacerts" Here is the output: ...
cn=digicert_trusted_root_g4,ou=www.digicert.com,o=digicert_inc,c=us, 13 Mar 2024, trustedCertEntry,
Certificate fingerprint (SHA-256): 55:2F:7B:DC:F1:A7:AF:9E:6C:E6:72:01:7F:4F:12:AB:F7:72:40:C7:8E:76:1A:C2:03:D1:D9:D2:0A:C8:99:88
... Could you please confirm that the DigiCert root cert already included in your cacerts too? 2. Sign by the cert provided by DigiCert.
I found this doc: https://knowledge.digicert.com/tutorials/export-your-ssl-certificate-using-the-digicert-certificate-utility-pfx-format To sign a jar file, a private key is necessary. For security reason, sometimes the private key is not exportable. We can ignore the part of 3. What to do next step?Please confirm these things:
|
Hello @rujche Sorry for the delay, we had to stop debugging this issue for a while in order to manually sign, with a hardware token, a product release. So, I have checked that the DigiCert root CA is included in the cacerts.
For your second point, "investigate why import manually is necessary", I can relate the following:
When signing the So my guess is there is something not working properly in the way the certificates are retrieved from Azure KeyVault. |
We have also hit this with a non-exportable HSM backed key. We have reissued the certificate multiple times and merged bundles in to new versions of KV certificates:
With just the leaf we can sign but it is not trusted until we add the intermediate in to the cacerts store. With scenarios 2 and 3 jarsigner reports that everything is signed successfully, but verify says otherwise:
With the debug enabled:
Our intermediate CA is |
Hi, @3millionminds Sorry for late response.
This looks good because the whole chain appeared when sign the file. What to do next
|
Closing this issue now, please reopen it if the issue is not resolved. |
@3millionminds did this work for you? |
@saragluna this still doesn't work, please could you reopen? If you use a standard RSA key it works with a self-signed multi-tier openssl-based certificate authority. The PEM file containing the signed certificate contains "root => intermediate => signed_cert" in that order. Verify works here if my root is in the cacerts. If you use a key of type RSA-HSM and a DigiCert signed certificate it does not work. It doesn't work if I self sign a RSA-HSM backed cert either via the previously mentioned openssl-based CA. The verify of the DigiCert RSA-HSM cert shows:
The verify is reporting that the signature is from the DigiCert root, and not the DigiCert issued code signing certificate. Interestingly enough if I run the META-INF/2024OVCS.RSA through openssl you can see that the full chain is there:
The DigiCert root is also in the Java's cacerts. The problem definitely is around HSM backed/non-exportable keys. |
Hello, Unfortunately we have been unable to test. We have opened a MS ticket to see what options we have here. |
More data points. Given an exportable RSA key type with the self-signed setup the output of verify is:
This is good. Extracting the signed jar and running META-INF/2024OVCS.RSA through openssl:
Notice the order: LEAF => INTERMEDIATE => ROOT. The signed CSR was imported in to a Key Vault as merge operation. The PEM file used contained the full chain in this order: ROOT => INTERMEDIATE => LEAF. If I do the same process as above for a HSM backed key using the same openssl multi-tier CA we get different results. The output of verify is:
This is bad. It has attempted to sign with the intermediate CA and not the leaf. Extracting the signed jar and running at META-INF/SSMULTI.RSA file through openssl:
Its all in the same order... The issue seems to be: the signing operation is picking the wrong certificate when it is a HSM backed key. |
@3millionminds is your problem solved? Once a certificate operation is completed, you cannot merge another certificate (exported by DigiCert). If you need to merge again, please re-create the certificate in Key Vault, re-apply on DigiCert and then merge. |
Hi @dacron , thanks for your update!
I cannot generate a certificate with key type RSA-HSM on Azure Portal, For a premium Key Vault, it supports to generate a key with key type RSA-HSM, but how to generate a certificate using an existing key (RSA-HSM type)? Could you help provider more detail steps to create a cert chain with key type RSA-HSM on Azure Key Vault? This will be very helpful to verify this scenario. |
@moarychan I can help you with this |
Hi @dacron, thanks for your update! I can use the private key type RSA-HSM and key size 3072 to generate a cert and signed with DiGiCert, it works well, could you follow below steps to retry?
|
This works with the beta release of 2.10! Is it expected to work with 2.9.0 at all? |
Hi, @dacron I can't see Now I plan to release |
Yes - I built 2.10.0 beta 1 from source. Getting 2.9.1 out of the door would be much appreciated. |
@rujche are you able to let me know which commit fixes the bug? |
@dacron
|
JCA 2.10.0 is available on Maven Central, please try it! Thanks! |
Describe the bug
When using a valid, DigiCert issued, non-exportable Azure Key Vault certificate to sign a
.jar
file withjarsigner + jca 2.8.2
ORjarsigner + jca 2.9.0-beta.3
, the file is signed with apparently no issues.However, upon verifying the file, a warning is produced:
This prevents the jar file to run on high-security systems, and we are unable to run the applications.
Exception or Stack Trace
jca282_signing.log
jca282_verify.log
jca282_environment.log
jca290_signing.log
jca290_verify.log
jca290_environment.log
To Reproduce
Steps to reproduce the behavior:
Sign a JAR file with
jarsigner
andazure-security-keyvault-jca-2.8.2.jar
(or 2.9.0-beta.3), with a valid certificate issued by DigiCert and stored in AzKV.Verify it's signature
Expected behavior
There
.jar
should be signed, and there should be no warnings when verifying the signature.Screenshots
Setup (please complete the following information):
com.azure:azure-security-keyvault-jca:2.8.2
com.azure:azure-security-keyvault-jca:2.9.0-beta.3
(built from rev ac9ee6330b6)Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: