azure-sdk-for-java: [BUG] jarsigner + jca reports that entries in certificate chain are invalid
Describe the bug
When using a valid, DigiCert issued, non-exportable Azure Key Vault certificate to sign a .jar file with jarsigner + jca 2.8.2 OR jarsigner + jca 2.9.0-beta.3, the file is signed with apparently no issues.
>>> Signer
X.509, CN=██████████ Limited, O=██████████ Limited, L=London, C=GB
[trusted certificate]
jar signed.
However, upon verifying the file, a warning is produced:
This jar contains entries whose certificate chain is invalid.
Reason:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
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
jarsignerandazure-security-keyvault-jca-2.8.2.jar(or 2.9.0-beta.3), with a valid certificate issued by DigiCert and stored in AzKV.$ jarsigner -keystore NONE -storetype AzureKeyVault \ -signedjar SIGNED_SignMe.jar SignMe.jar "██████████CodeSigning" \ -verbose -storepass "" \ -tsa "http://timestamp.digicert.com/" \ -providerName AzureKeyVault \ -providerClass com.azure.security.keyvault.jca.KeyVaultJcaProvider \ -J-Dazure.keyvault.uri="██████████" \ -J-Dazure.keyvault.tenant-id="██████████" \ -J-Dazure.keyvault.client-id="██████████" \ -J-Dazure.keyvault.client-secret="██████████" [lines omitted] >>> Signer X.509, CN=██████████ Limited, O=██████████ Limited, L=London, C=GB [trusted certificate] jar signed. -
Verify it’s signature
$ jarsigner -verify SIGNED_SignMe.jar jar verified. Warning: This jar contains entries whose certificate chain is invalid. Reason: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Expected behavior
There .jar should be signed, and there should be no warnings when verifying the signature.
Screenshots
Setup (please complete the following information):
- OS: (containerized) Red Hat Enterprise Linux release 8.10 (Ootpa)
- IDE: N/A
- Library/Libraries:
com.azure:azure-security-keyvault-jca:2.8.2com.azure:azure-security-keyvault-jca:2.9.0-beta.3(built from rev ac9ee6330b6)
- Java version: openjdk-1.8.0_422
- App Server/Environment: N/A
- Frameworks: N/A
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
- Bug Description Added
- Repro Steps Added
- Setup information Added
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 38 (20 by maintainers)
JCA 2.10.0 is available on Maven Central, please try it! Thanks!
@dacron Our plan updated. Here is the new plan:
@dacron Sorry, my mistake. It should be this one: https://github.com/Azure/azure-sdk-for-java/pull/41303
@dacron This one: ~https://github.com/Azure/azure-sdk-for-java/pull/42522~ https://github.com/Azure/azure-sdk-for-java/pull/41303
Hi, @3millionminds
Good news: I reproduced this issue and fixed it.
1. Reproduce this issue.
1.1. Create a certificate in Azure Portal by configurations like this:
1.2. Download csr from Azure Portal, then upload to by DigiCert: https://www.digicert.com/, sign it.
1.3. Download the .crt (best for Apache / Linux) from DigiCert, then upload to Azure Portal.
1.4. Use it to sign and verify, problem reproduced.
2. Fix it
2.1. In step 1.3, download A single .pem file contains all certs instead of .crt (best for Apache / Linux)
2.2. Other steps same to step 1. Problem solved.
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
DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1and the root isDigiCert Trusted Root G4HI @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!