/// <summary> /// 解密数据密钥 /// </summary> public async Task <DecryptDatakeyResponse> DecryptDatakeyAsync(DecryptDatakeyRequest decryptDatakeyRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("version_id", decryptDatakeyRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/decrypt-datakey", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", decryptDatakeyRequest); HttpResponseMessage response = await DoHttpRequestAsync("POST", request); return(JsonUtils.DeSerialize <DecryptDatakeyResponse>(response)); }
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); }