我已遵循文档https://github.com/backwind1233/AzureDocs/blob/main/AzureJavaSDK/JCA/integrate_keyvault_JCA_provider_with_jarsigner.md#step-1--download-and-configure-jca-provider-jar并运行使用 jarsigner 和 Azure Key Vault 证书组合对 jar 进行签名的命令,但出现以下错误。
jarsigner 错误:java.lang.RuntimeException:无法实例化密钥库类:找不到 AZUREKEYVAULT java.lang.RuntimeException:无法实例化密钥库类:在 jdk.jartool/sun.security.tools.jarsigner.Main.loadKeyStore 找不到 AZUREKEYVAULT (Main.java:2295) 在 jdk.jartool/sun.security.tools.jarsigner.Main.run(Main.java:303) 在 jdk.jartool/sun.security.tools.jarsigner.Main.main(Main.java :138)
我运行了以下命令,但收到错误“未找到 AZUREKEYVAULT”。尝试了很多组合但都没能成功。
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)
echo $CLASSPATH
验证 Azure Key Vault JCA 提供程序 jar 文件在类路径中提到的目录之一中是否可用。
删除现有的 Azure Key Vault JCA 提供程序 jar 文件并重新下载并将其移动到基于 Java 版本的位置。
providerName 应为“AzureKeyVault”,providerClass 应为“com.azure.security.keyvault.jca.KeyVaultJcaProvider”,并指向 Azure Key Vault JCA 提供程序 jar 文件的正确位置。
密钥库类型应设置为
AzureKeyVault
且密码正确。
验证命令中使用的 Azure Key Vault URI、租户 ID、客户端 ID 和客户端密钥是否正确且可用。
登录到 Azure CLI 并再次运行命令,或者手动创建资源并直接在命令中使用值。
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>
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>