我的解决方案涉及使用Java在密钥仓库中创建证书。以下是我尝试执行但未成功的方法。
CertificateClient certificateClient = new CertificateClientBuilder()
.vaultUrl("https://valueUrl.vault.azure.net")
.credential(new DefaultAzureCredentialBuilder().build()).buildClient();
ClientCertificateCredential certCreds = new ClientCertificateCredentialBuilder()
.clientId("clientId")
.pfxCertificate("C:\\MyCerft.pfx", "123")
.tenantId("tenantId").build();
CertificateClient certificateClient1 = new CertificateClientBuilder()
.vaultUrl("https://vaultUrl.vault.azure.net/")
.credential(certCreds).buildClient();
示例来源如下:
但是,以上两种方法在credentialBuilder类中都抛出了与
相同的签名不匹配错误。com.azure.security.keyvault.certificates.CertificateClientBuilder"'s signer information does not match
signer information of other classes in the same package
下面是我的pom文件中的依赖项:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-certificates</artifactId>
<version>4.0.0</version>
</dependency> `
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.0.4</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
</dependency>
我真的很想第二种方式,因为这更加安全,可以让我进行一些在第一种情况下必须设置的配置设置。但是,在这一点上,如果有结果的话,我什至会优先考虑。
此外,我不明白为什么第二种方式,Microsoft没有将客户端机密作为参数提供,而是期望解决方案的证书(pfx / pem)进行身份验证。因此,我认为SDK应该允许接受两种访问方式。
任何有关我可能在此处遗漏的建议都将大有帮助,因为这是我直接从Microsoft的官方文档中挑选的。
欢呼
答案 0 :(得分:0)
可能是一个错误。我使用以下版本的SDK解决了该问题:
<!-- https://mvnrepository.com/artifact/com.azure/azure-identity -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.0-beta.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.azure/azure-security-keyvault-certificates -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-certificates</artifactId>
<version>4.1.0-beta.1</version>
</dependency>