[BUG] KeyEncryptionKeyClientBuilder.buildKeyEncryptionKey().getKeyId(String keyId) leads to NullPointerException
See original GitHub issueDescribe the bug In com.azure:azure-security-keyvault-keys:4.0.0, use com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClientBuilder.buildKeyEncryptionKey().getKeyId(String keyId) leads to NullPointerException
Exception or Stack Trace
java.lang.NullPointerException: null
at com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyAsyncClient.getKeyId(KeyEncryptionKeyAsyncClient.java:38) ~[azure-security-keyvault-keys-4.0.0.jar:na]
at com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClient.getKeyId(KeyEncryptionKeyClient.java:28) ~[azure-security-keyvault-keys-4.0.0.jar:na]
at com.example.demo.DemoApplication.test(DemoApplication.java:49) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at com.example.demo.DemoApplication.main(DemoApplication.java:28) ~[classes/:na]
To Reproduce Steps to reproduce the behavior: I have put the reproducible codes in https://github.com/chpoon92/azure-key-vault-bugs Preparation:
- Azure key vault url
- Service principal that can access key vault
- tenant-id
- client id
- client secret
- Key name of an existing key in key vault
- Put above values in the config file /src/main/resources/application.yml
Run: In cmd, execute
mvn spring-boot:run
Code Snippet I have put in /src/main/java/com/example/demo/DemoApplication.java In function test()
Expected behavior Key id returned by com.azure.security.keyvault.keys.models.KeyVaultKey should be same as key id returned by com.azure.core.cryptography.KeyEncryptionKey
Setup (please complete the following information):
- OS: Windows
- IDE : IntelliJ
- JDK : OpenJDK 11
- Build tools : Maven 3.6.2
- Library:
- com.azure:azure-security-keyvault-keys:4.0.0
- com.azure:azure-identity:1.0.0
- org.springframework.boot:spring-boot-starter:2.2.1.RELEASE
Additional context The purpose of using com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClientBuilder is because I need to apply Azure Key Vault to client side encryption of Azure Storage. The setup in com.azure:azure-storage-blob-cryptography:12.0.0 requires an instance of com.azure.core.cryptography.AsyncKeyEncryptionKeyResolver, which is the interface implemented by KeyEncryptionKeyClientBuilder.
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
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
The fix for this issue has been merged into the master. It will be released as part of the KV release going out tomorrow on 7th Jan 2020.
@chpoon92 Thank you for posting this issue again. Since the root issue is resolved, we’ll be closing this issue. Do reach out to us, If you spot any other issues.