Esempio n. 1
0
        private static DecryptDatakeyResponse DecryptDataKey(KmsClient kmsClient)
        {
            try
            {
                var cipherText = CreateDataKey(kmsClient).CipherText;
                var request    = new DecryptDatakeyRequest
                {
                    VersionId = "v1.0",
                    Body      = new DecryptDatakeyRequestBody()
                    {
                        KeyId               = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"),
                        CipherText          = cipherText,
                        DatakeyCipherLength = "64"
                    }
                };
                var resp = kmsClient.DecryptDatakey(request);
                Console.WriteLine(resp.ToString());
                return(resp);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }

            return(null);
        }