I am trying to create a KeyVaultClient
object from the Azure Java SDK
from a pfx certificate. I found a clear document on how to do that in C# but have to clue how to do it in Java.
I am able to get a Windows certificate from the user account keystore
, but I do not really know what to pass to the KeyVaultClient
constructor. It looks like it accepts object of type TokenCredentials
, but I cannot find any document on how to actually build one of those (which needs a "token" and a "scheme").
It seems I am close to have something working by defining this class:
}
And trying to use it after getting a certificate X509Certificate object and private key using java.security.KeyStore:
Unfortunately it raises an exception:
I opened an issue on github AzureAD/azure-activedirectory-library-for-java and proposed a pull request to fix it, to be continued...
Edit: this is now fixed in version 1.2.0 of AzureAD/azure-activedirectory-library-for-java.