private static CreateParametersForImportResponse GetParametersForImport(KmsClient kmsClient, string keyId) { try { var req = new CreateParametersForImportRequest { VersionId = "v1.0", Body = new GetParametersForImportRequestBody { KeyId = keyId, WrappingAlgorithm = GetParametersForImportRequestBody.WrappingAlgorithmEnum.RSAES_OAEP_SHA_1 } }; var resp = kmsClient.CreateParametersForImport(req); 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); }
/// <summary> /// 获取密钥导入参数 /// </summary> public CreateParametersForImportResponse CreateParametersForImport(CreateParametersForImportRequest createParametersForImportRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("version_id", createParametersForImportRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/get-parameters-for-import", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createParametersForImportRequest); HttpResponseMessage response = DoHttpRequestSync("POST", request); return(JsonUtils.DeSerialize <CreateParametersForImportResponse>(response)); }