javaazure-keyvaultjarsignerjar-signing

Getting error "AZUREKEYVAULT not found" while trying to sign the jar using jarsigner with Azure Key Vault Java 17/21


I have followed the documentation https://github.com/backwind1233/AzureDocs/blob/main/AzureJavaSDK/JCA/integrate_keyvault_JCA_provider_with_jarsigner.md#step-1--download-and-configure-jca-provider-jar and ran the command to sign the jar using the jarsigner with Azure Key Vault certificate combination but getting the below error.

jarsigner error: java.lang.RuntimeException: unable to instantiate keystore class: AZUREKEYVAULT not found java.lang.RuntimeException: unable to instantiate keystore class: AZUREKEYVAULT not found at jdk.jartool/sun.security.tools.jarsigner.Main.loadKeyStore(Main.java:2295) at jdk.jartool/sun.security.tools.jarsigner.Main.run(Main.java:303) at jdk.jartool/sun.security.tools.jarsigner.Main.main(Main.java:138)

I ran below command but getting the error "AZUREKEYVAULT not found". Tried many combination but not able to succeed.

jarsigner -keystore NONE -storetype AzureKeyVault \
          -sigalg SHA512withRSA \
          -signedjar /root/signed.jar /root/naveen.jar "jarsign" \
          -storepass '12345' \
          -providerPath /root/azure-security-keyvault-jca-2.8.1.jar \
          -providerName AzureKeyVault \
          -providerClass com.azure.security.keyvault.jca.KeyVaultJcaProvider \
          -J--module-path="/root/azure-security-keyvault-jca-2.8.1.jar" \
          -J--add-modules="com.azure.security.keyvault.jca" \
          -J-Dazure.keyvault.uri=https://abc.vault.azure.net  \
          -J-Dazure.keyvault.tenant-id=xxxxx \
          -J-Dazure.keyvault.client-id=Jxxxxx \
          -J-Dazure.keyvault.client-secret=xxxx \
          -debug 
Command line args: [-keystore, NONE, -storetype, AzureKeyVault, -sigalg, SHA512withRSA, -signedjar, /root/signed.jar, /root/naveen.jar, jarsign, -storepass, 12345, -providerPath, /root/ttt.jar, -providerName, AzureKeyVault, -providerClass, com.azure.security.keyvault.jca.KeyVaultJcaProvider, -debug]
loadProviderByClass: com.azure.security.keyvault.jca.KeyVaultJcaProvider
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.KeyVaultClient <init>
INFO: Using Azure Key Vault: https://filesigning-jar-poc.vault.azure.net
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.utils.AccessTokenUtil getAccessToken
INFO: Getting access token using client ID / client secret
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.KeyVaultClient <init>
INFO: Using Azure Key Vault: https://filesigning-jar-poc.vault.azure.net
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.utils.AccessTokenUtil getAccessToken
INFO: Getting access token using client ID / client secret
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.KeyVaultClient <init>
INFO: Using Azure Key Vault: https://filesigning-jar-poc.vault.azure.net
May 03, 2024 11:33:21 PM com.azure.security.keyvault.jca.implementation.utils.AccessTokenUtil getAccessToken
INFO: Getting access token using client ID / client secret
jarsigner error: java.lang.RuntimeException: unable to instantiate keystore class: AZUREKEYVAULT not found
java.lang.RuntimeException: unable to instantiate keystore class: AZUREKEYVAULT not found
        at jdk.jartool/sun.security.tools.jarsigner.Main.loadKeyStore(Main.java:2295)
        at jdk.jartool/sun.security.tools.jarsigner.Main.run(Main.java:303)
        at jdk.jartool/sun.security.tools.jarsigner.Main.main(Main.java:138)

Solution

  •     echo $CLASSPATH
    

    keytool -list -keystore NONE -storetype AzureKeyVault -storepass "" -providerName AzureKeyVault -providerClass com.azure.security.keyvault.jca.KeyVaultJcaProvider -J--module-path="<JAVA_HOME>\azure-security-keyvault-jca-2.8.1.jar" -J--add-modules="com.azure.security.keyvault.jca" -J-Dazure.keyvault.uri=https://keyvault.vault.azure.net/ -J-Dazure.keyvault.tenant-id=<tenant_id> -J-Dazure.keyvault.client-id=<client_id> -J-Dazure.keyvault.client-secret=<client_secret>
    

    enter image description here

    jarsigner   -keystore NONE -storetype AzureKeyVault -signedjar signerjar.jar "<jarfile.jar>" "mycert1.cert" -verbose  -storepass "" -providerName AzureKeyVault -providerClass com.azure.security.keyvault.jca.KeyVaultJcaProvider -J--module-path="<JAVA_HOME>\azure-security-keyvault-jca-2.8.1.jar" -J--add-modules="com.azure.security.keyvault.jca" -J-Dazure.keyvault.uri=https://keyvaultname.vault.azure.net/ J-Dazure.keyvault.tenant-id=<tenant_id> -J-Dazure.keyvault.client-id=<client_id> -J-Dazure.keyvault.client-secret=<client_secret>