[BUG] NullPointerException thrown when calling JsonWebKey.toRsa() #16761
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
KeyVault
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone
Describe the bug
Using azure-security-keyvault-keys: 4.2.2 with JDK11
//using the secretKey (keyClient.getKey(key))
JsonWebKey jSonWebKey1=VaultAgent.getKey("key").getKey(); // this is just a wrapper
the key is built both with openssl and azure vault generator (type RSA)
when KeyPair kp=jSonWebKey1.toRsa(true); a nullPointer exception occurs
Exception or Stack Trace
Add the exception log and stack trace if available
java.lang.NullPointerException
[2020-10-23T14:32:34.320] at com.azure.security.keyvault.keys.models.JsonWebKey.toBigInteger(JsonWebKey.java:633)
[2020-10-23T14:32:34.320] at com.azure.security.keyvault.keys.models.JsonWebKey.getRsaPrivateKeySpec(JsonWebKey.java:548)
[2020-10-23T14:32:34.320] at com.azure.security.keyvault.keys.models.JsonWebKey.getRsaPrivateKey(JsonWebKey.java:580)
[2020-10-23T14:32:34.320] at com.azure.security.keyvault.keys.models.JsonWebKey.toRsa(JsonWebKey.java:720)
[2020-10-23T14:32:34.321] at com.azure.security.keyvault.keys.models.JsonWebKey.toRsa(JsonWebKey.java:703)
[2020-10-23T14:32:34.321] at com.grupoica.core.utils.security.jwt.JWT.buildAndSignJWT(JWTAgent.java:145)
[2020-10-23T14:32:34.321] at com.grupoica.core.utils.security.jwt.JWT.(JWTAgent.java:100)
[2020-10-23T14:32:34.321] at com.grupoica.core.utils.security.jwt.JWT.getCredentials(JWTAgent.java:195)
[2020-10-23T14:32:34.321] at com.grupoica.core.utils.security.jwt.JWTAgent.getCredentials(JWTAgent.java:44)
[2020-10-23T14:32:34.321] at com.grupoica.core.OAuth.run(OAuth.java:55)
[2020-10-23T14:32:34.321] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2020-10-23T14:32:34.321] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2020-10-23T14:32:34.321] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2020-10-23T14:32:34.321] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[2020-10-23T14:32:34.321] at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:22)
[2020-10-23T14:32:34.321] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:55)
[2020-10-23T14:32:34.321] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:57)
[2020-10-23T14:32:34.322] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[2020-10-23T14:32:34.322] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2020-10-23T14:32:34.322] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[2020-10-23T14:32:34.322] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[2020-10-23T14:32:34.322] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[2020-10-23T14:32:34.322] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2020-10-23T14:32:34.322] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[2020-10-23T14:32:34.322] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[2020-10-23T14:32:34.322] at java.base/java.lang.Thread.run(Thread.java:834)
To Reproduce
Steps to reproduce the behavior:
create/import a RSA key in azure vault
this is a fake (working) private rsa priv key
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA4dUjwk6DqoJOFwsJV+ielsDASOYG5i7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UVyrSZLXIUJI72J1ridec22/KIToSjb1KxyO28DQ9gbaHtPdxa7
Fgnd7tqd6U/R3Zly1W8z/L5PnkhbN2XxrXohsyISPuR3arXh1S1amqWCgJY5yjbG
nAypWOq0eVdKBlapfD58Wg0CgYEAjqWJIx7DLPFedOrAAa+APTrBxIJghrK8gke/
CJAjqCvhPBDfp7DtGUrCSbQZfRtK8Z19VSu3MVcDPIX4heY2npULp+1DwKBBT2Ss
iCWpmYtvDa0hiorl8gRL/1/0OKZodnSXFq013JBeP+t4g012/tMUwfTLI4zJw/D6
TgBy9isCgYAGs3K9AKmnT7QemJSp7CoD16+vsRz4oQ10TrS+7iQUUBcVhaicsfwh
I6hNxxRIx7jss7X0wkVxr4MsoJQMNC3dzB3jhGoHjRCyIkcjfMehuoL7BBpXpu8K
XQ8xQKGoKqKY5qZeMirdzRCak7/APaXpgN2AIUqzQrbpTWXnCdhOMA==
-----END RSA PRIVATE KEY-----
access to the key via vualt key client and retrieve the JsonWebKey
keyClient.getKey(key))
JsonWebKey jSonWebKey1=VaultAgent.getKey("key").getKey(); // this is just a wrapper
when KeyPair kp=jSonWebKey1.toRsa(true); a nullPointer exception occurs
Code Snippet
Add the code snippet that causes the issue.
Expected behavior
a working keyPair with both keys
Screenshots
Setup (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: