0

I am new to the disk encryption. I have generated a random key using AES 256bit. Then I created a key in Azure key vault. Using java SDK i wrapped my random key using the key I have created in Azure key vault and gave algorithm as JsonWebKeyEncryptionAlgorithm.RSA1_5. Then I created a secret in the Azure key vault with value as this wrapped key. Please find below the code.

byte[] newSecret = azure.vaults().getByResourceGroup("myResourceGroup", "MyVaultName").keys().getById("https://MyVaultName.vault.azure.net/keys/MyKeyName1/eb9fe2725e2342f5b99e866746646b85").wrapKey(JsonWebKeyEncryptionAlgorithm.RSA1_5,MyRandomKeyUsingAES);

Map<String,String> tags = new HashMap<String,String>();
            tags.put("DiskEncryptionKeyFileName", "MySecretName");
            tags.put("DiskEncryptionKeyEncryptionAlgorithm", "RSA1_5");
            tags.put("DiskEncryptionKeyEncryptionKeyURL", "https://MyVaultName.vault.azure.net/keys/MyKeyName/eb9fe2725e2342f5b99e866746646b85");

Secret ss = azure.vaults().getByResourceGroup("myResourceGroup", "MyVaultName").secrets().define("MySecretName").withValue("[B@4cd1c1dc").withTags(tags).create();


When i am making an rest api call to create a VM and gave the encryptioSettings as below, I am getting following error.

"encryptionSettings": {
          "enabled": true,
          "diskEncryptionKey": {
            "sourceVault": {
              "id": "/subscriptions/MYSUB/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/MyVaultName"
            },
            "secretUrl": "https://MyVaultName.vault.azure.net/secrets/MySecretName/3c6c28a8ef204ca2904ea53f1db4f231"
          },
          "keyEncryptionKey": {
            "sourceVault": {
              "id": "/subscriptions/MYSUB/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/MyVaultName"
            },
            "keyUrl": "https://MyVaultName.vault.azure.net/keys/MyKeyName/eb9fe2725e2342f5b99e885646646b85"
          }
        }
      }

Error:"Unwrap of secret https://MyVaultName.vault.azure.net/secrets/MySecretName/3c6c28a8ef204ca2904ea53f1db4f231 value using key https://MyVaultName.vault.azure.net/keys/MyKeyName/eb9fe2725e2342f5b99e885646646b85 failed."

i am wrapping using the same key and i gave the required tags as well. But still it is failing. the tags are DiskEncryptionKeyFileName as my secretName,DiskEncryptionKeyEncryptionAlgorithm is the algorithm I used to wrap secret and DiskEncryptionKeyEncryptionKeyURL is the url of Key that I used to wrap the secret.

Can anyone please help me on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.