You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Create a key with name 'firstKey' of any type in key vault.
KeyClientkeyClient = KeyClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
Keykey = keyClient.createKey("firstKey", KeyType.EC).value();
System.out.printf("Key is created with name %s and id %s \n", key.name(), key.id());
2. Create an RSA HSM key of size 2048 and ensure it expires in 1 year.
KeyClientkeyClient = KeyClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
KeycreatedKey = keyClient.createRSAKey(newRSAKeyCreateConfig("myRsaHsmKey", KeyType.RSA_HSM)
.expires(OffsetDateTime.now().plusYears(1))
.keySize(2048))
.value();
System.out.printf("Key is created with name %s and value %s \n", createdKey.name(), createdKey.id());
3. Given a key named "myRsaHsmKey" whose expiry got changed to 2 years from today, update it in key vault.
1. Create a key with name 'firstKey' of any type in key vault.
KeyAsyncClientkeyAsyncClient = KeyAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
keyAsyncClient.createKey("firstKey", KeyType.EC).subscribe(keyResponse ->
System.out.printf("Key is created with name %s and id %s \n", keyResponse.value().name(), keyResponse.value().id()));
2. Create an RSA HSM key of size 2048 and ensure it expires in 1 year.
KeyAsyncClientkeyAsyncClient = KeyAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
RSAKeyCreateConfigrsaKeyConfig = newRSAKeyCreateConfig("myRsaHsmKey", KeyType.RSA_HSM)
.expires(OffsetDateTime.now().plusYears(1))
.keySize(2048);
keyAsyncClient.createRSAKey(rsaKeyConfig).subscribe(keyResponse ->
System.out.printf("Key is created with name %s and id %s \n", keyResponse.value().name(), keyResponse.value().id()));
3. Given a key named "myRsaHsmKey" whose expiry got changed to 2 years from today, update it in key vault.
KeyAsyncClientkeyAsyncClient = KeyAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
keyAsyncClient.getKey("myRsaHsmKey").subscribe(keyResponse -> {
Keykey = keyResponse.value();
//Update the expiry time of the key.key.expires(OffsetDateTime.now().plusYears(2));
keyAsyncClient.updateKey(key).subscribe(updatedKeyResponse ->
System.out.printf("Key's updated expiry time %s \n", updatedKeyResponse.value().notBefore().toString()));
});
4. Given a key named "myTwitterECKey" which is no longer needed, delete it.