none
Getting SecretKey obj from KeyBundle obj.

    Question

  • Hi ,

    I have the java application which is successfully authenticate with Azure Key Vault. I have create key vault on azure portal.
    I am creating the key in key vault using following api.

    ClientSecretKeyVaultCredential rAzureKVC = new ClientSecretKeyVaultCredential(client_id, client_secret );
    KeyVaultClient kv = new KeyVaultClient(rAzureKVC);

    CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder("vaultBaseUrl", "msKey", JsonWebKeyType.RSA).build();
    KeyBundle keyBundle = kv.createKeyAsync(createKeyRequest, null).get();

    Questions:
    1.) How can i get SecretKey obj above keybundle obj?
    2.) How can i get encoded key string value from key bundle obj?

    Thanks.



    Tuesday, June 11, 2019 1:18 PM

All replies

  • Further i tried creating key using api as mentioned below

    CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder("keyVaultUrl", "msKey", JsonWebKeyType.RSA).build();
    KeyBundle keyBundle = kv.createKeyAsync(createKeyRequest, null).get();
    byte[] symKey = keyBundle.key().k(); ==> Getting null
    logger.info("Newly Created Key kid : " + keyBundle.key().kid()); ==> Getting kid as string.
    logger.info("Newly Created Key :  " + symKey);

    My key was successfully created on key vault but I am looking for encoded string value of key. I will be using this encoded key value further for some operation in my application.

    Is their anyway which can help me out over here?

    Thanks a lot in advance.
    Wednesday, June 12, 2019 12:40 PM