调用Amazon API Gateway时握手失败

时间:2016-09-01 16:53:27

标签: java amazon-web-services jax-rs resteasy aws-api-gateway

我得到了#34;握手失败"当我通过HTTPS调用Amazon API Gateway时。

我的代码如下:

final Client client = ClientBuilder.newClient();
final Response name = client.target("https://SOME_ID.execute-api.us-west-2.amazonaws.com/prod")
        .request(MediaType.APPLICATION_JSON)
        .header(HEADER_APIKEY, HEADER_APIKEY_VALUE)
        .post(Entity.json(myEntity));

错误是:

13:45:42,602 INFO  [stdout] (Batch Thread - 1) Batch Thread - 1, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
13:45:42,603 INFO  [stdout] (Batch Thread - 1) Batch Thread - 1, called close()
13:45:42,603 INFO  [stdout] (Batch Thread - 1) Batch Thread - 1, called closeInternal(true)
13:45:42,627 WARN  [org.jberet] (Batch Thread - 1) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact@77e69caf: javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request
    at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:287)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:436)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:195)

我做了一些编写本机Java代码的测试,并且工作正常。只有我使用Jaxrs才行不通。

    final URL url = new URL("https://SOME_ID.execute-api.us-west-2.amazonaws.com/prod");
    final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");
    conn.setRequestProperty(HEADER_APIKEY, HEADER_APIKEY_VALUE);

我的环境是JDK 1.8.0_92和Wildfly 10.0.0,它使用Resteasy。

我如何解决此错误?

(更新) 使用-Djavax.net.debug = ssl:handshake:verbose:https://gist.github.com/garcia-jj/9ca7704a690c36be09d4d2e44a4e33a7

记录日志

Resteasy版本:3.0.14 httpclient版本:4.5 httpcore版本:4.4.1

当我直接使用Resteasy时,它可以正常工作,而不是使用Jaxrs客户端。

ResteasyClient client = new ResteasyClientBuilder()
    .httpEngine(new URLConnectionEngine()).build();
final Response name = client.target("https://SOME_ID.execute-api.us-west-2.amazonaws.com/prod")
    .request(MediaType.APPLICATION_JSON)
    .header(HEADER_APIKEY, HEADER_APIKEY_VALUE)
    .post(Entity.json(myEntity));

0 个答案:

没有答案