我开始使用适用于Java的AWS开发工具包,特别是为了利用KMS服务。
我要做的第一件事是创建CMK密钥,因此,我将遵循官方文档提供的开发人员指南中的示例。
AWSKMS kmsClient = AWSKMSClientBuilder.standard().withClientConfiguration(clientConfiguration).build();
String desc = "Key for protecting critical data";
CreateKeyRequest req = new CreateKeyRequest().withDescription(desc);
CreateKeyResult keyResult = kmsClient.createKey(req);
但是,如果运行应用程序尝试创建CMK密钥,则会收到以下错误,但我不知道如何解决。
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (byte[])"<html><head><title>404 Not Found</title></head>
<body><h1>Host Not Found</h1>
<p>DNS error (the host name of the page you are looking for does not exist) or Server did not accept the connection.<br><br>Please check that the host name has been spelled correctly.<br></p>
<!--Zscaler/5.7--></body></html>
"; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:591)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2630)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:832)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:729)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4042)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2571)
at com.amazonaws.protocol.json.JsonContent.parseJsonContent(JsonContent.java:72)
at com.amazonaws.protocol.json.JsonContent.<init>(JsonContent.java:64)
at com.amazonaws.protocol.json.JsonContent.createJsonContent(JsonContent.java:54)
at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:61)
at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:33)
at com.amazonaws.http.AwsErrorResponseHandler.handleAse(AwsErrorResponseHandler.java:53)
at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:41)
at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:26)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1642)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1324)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1074)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:745)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:719)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:701)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:669)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:651)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:515)
at com.amazonaws.services.kms.AWSKMSClient.doInvoke(AWSKMSClient.java:3506)
at com.amazonaws.services.kms.AWSKMSClient.invoke(AWSKMSClient.java:3475)
at com.amazonaws.services.kms.AWSKMSClient.invoke(AWSKMSClient.java:3464)
at com.amazonaws.services.kms.AWSKMSClient.executeDescribeKey(AWSKMSClient.java:1126)
at com.amazonaws.services.kms.AWSKMSClient.describeKey(AWSKMSClient.java:1097)
at com.thalesgroup.aws.kms.KmsServiceTest.getCMKInformation(KmsServiceTest.java:51)
at com.thalesgroup.aws.kms.KmsServiceTest.main(KmsServiceTest.java:16)
17:38:32.994 [main] DEBUG com.amazonaws.request - Received error response: com.amazonaws.services.kms.model.AWSKMSException: null (Service: AWSKMS; Status Code: 404; Error Code: null; Request ID: null)
Exception in thread "main" com.amazonaws.services.kms.model.AWSKMSException: null (Service: AWSKMS; Status Code: 404; Error Code: null; Request ID: null)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1660)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1324)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1074)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:745)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:719)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:701)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:669)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:651)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:515)
at com.amazonaws.services.kms.AWSKMSClient.doInvoke(AWSKMSClient.java:3506)
at com.amazonaws.services.kms.AWSKMSClient.invoke(AWSKMSClient.java:3475)
at com.amazonaws.services.kms.AWSKMSClient.invoke(AWSKMSClient.java:3464)
at com.amazonaws.services.kms.AWSKMSClient.executeDescribeKey(AWSKMSClient.java:1126)
at com.amazonaws.services.kms.AWSKMSClient.describeKey(AWSKMSClient.java:1097)
at com.thalesgroup.aws.kms.KmsServiceTest.getCMKInformation(KmsServiceTest.java:51)
at com.thalesgroup.aws.kms.KmsServiceTest.main(KmsServiceTest.java:16)
似乎有两个错误,一个是JsonParseException,另一方面,作为响应的一部分,打印了404错误代码,无法解析。
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (byte[])"<html><head><title>404 Not Found</title></head>
<body><h1>Host Not Found</h1>
<p>DNS error (the host name of the page you are looking for does not exist) or Server did not accept the connection.<br><br>Please check that the host name has been spelled correctly.<br></p>
<!--Zscaler/5.7--></body></html>
有人可以帮我吗?
谢谢!