Example #1
0
        private async Task GenerateMasterKey(string keyAlias)
        {
            var createKeyResponse = await mAmazonKeyManagementService.CreateKeyAsync(new CreateKeyRequest { });

            if (mEnableAutomaticKeyRotation)
            {
                await mAmazonKeyManagementService.EnableKeyRotationAsync(
                    new EnableKeyRotationRequest
                {
                    KeyId = createKeyResponse.KeyMetadata.KeyId
                });
            }
            await mAmazonKeyManagementService.CreateAliasAsync(keyAlias, createKeyResponse.KeyMetadata.KeyId);
        }
Example #2
0
        private async Task GenerateMasterKey(string keyAlias)
        {
            var createKeyResponse = await mAmazonKeyManagementService.CreateKeyAsync(new CreateKeyRequest { });

            if (mEnableAutomaticKeyRotation)
            {
                await mAmazonKeyManagementService.EnableKeyRotationAsync(
                    new EnableKeyRotationRequest
                {
                    KeyId = createKeyResponse.KeyMetadata.KeyId
                });
            }

            await Policy
            .Handle <NotFoundException>()
            .WaitAndRetry(3, attempt => TimeSpan.FromSeconds(0.5 * attempt))
            .Execute(async() =>
                     await mAmazonKeyManagementService.CreateAliasAsync(keyAlias, createKeyResponse.KeyMetadata.KeyId));
        }
Example #3
0
 private Amazon.KeyManagementService.Model.EnableKeyRotationResponse CallAWSServiceOperation(IAmazonKeyManagementService client, Amazon.KeyManagementService.Model.EnableKeyRotationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Key Management Service", "EnableKeyRotation");
     try
     {
         #if DESKTOP
         return(client.EnableKeyRotation(request));
         #elif CORECLR
         return(client.EnableKeyRotationAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }