简体   繁体   English

如何在 AWS Lambda 中调用 SSL 安全的 REST 服务

[英]How to call a SSL secured REST service within AWS Lambda

Is it possible to do an REST call to https://owapi.net/api/v3/u/<Playername>-<BattleTagNumber>/stats via the JAX RS REST client withi AWS Lambda and if so, what do I have to set up with the Java SSL?是否可以通过带有 AWS Lambda 的 JAX RS REST 客户端对https://owapi.net/api/v3/u/<Playername>-<BattleTagNumber>/stats进行 REST 调用,如果可以,我需要做什么使用 Java SSL 设置? Currently I do the following:目前我执行以下操作:

  System.setProperty("javax.net.debug", "all");
  SSLContext sc = SSLContext.getInstance("TLSv1.2");
  System.setProperty("https.protocols", "TLSv1.2");//Java 8


  TrustManager[] trustAllCerts = { new InsecureTrustManager() };
  sc.init(null, trustAllCerts, new java.security.SecureRandom());
  HostnameVerifier allHostsValid = new InsecureHostnameVerifier();

  client = ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier(allHostsValid).build();

But if I do so, I always get the following error:但是如果我这样做,我总是会收到以下错误:

javax.ws.rs.ProcessingException: javax.net.ssl.SSLException: Received fatal alert: internal_error

With that javax.net.debug protocol:使用 javax.net.debug 协议:

trigger seeding of SecureRandom
done seeding SecureRandom
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
main, setSoTimeout(0) called
%% No cached client session
*** ClientHello, TLSv1.2
RandomCookie:  GMT: 1483983009 bytes = { 69, 214, 28, 204, 137, 202, 87, 217, 243, 178, 105, 174, 241, 76, 84, 41, 220, 36, 75, 185, 115, 175, 147, 24, 3, 43, 157, 220 }
Session ID:  {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods:  { 0 }
Extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1}
Extension ec_point_formats, formats: [uncompressed]
Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA, MD5withRSA
***
[write] MD5 and SHA1 hashes:  len = 207
0000: 01 00 00 CB 03 03 58 74   C9 A1 45 D6 1C CC 89 CA  ......Xt..E.....
0010: 57 D9 F3 B2 69 AE F1 4C   54 29 DC 24 4B B9 73 AF  W...i..LT).$K.s.
0020: 93 18 03 2B 9D DC 00 00   46 C0 23 C0 27 00 3C C0  ...+....F.#.'.<.
0030: 25 C0 29 00 67 00 40 C0   09 C0 13 00 2F C0 04 C0  %.).g.@...../...
0040: 0E 00 33 00 32 C0 2B C0   2F 00 9C C0 2D C0 31 00  ..3.2.+./...-.1.
0050: 9E 00 A2 C0 08 C0 12 00   0A C0 03 C0 0D 00 16 00  ................
0060: 13 C0 07 C0 11 00 05 C0   02 C0 0C 00 04 00 FF 01  ................
0070: 00 00 5C 00 0A 00 34 00   32 00 17 00 01 00 03 00  ..\...4.2.......
0080: 13 00 15 00 06 00 07 00   09 00 0A 00 18 00 0B 00  ................
0090: 0C 00 19 00 0D 00 0E 00   0F 00 10 00 11 00 02 00  ................
00A0: 12 00 04 00 05 00 14 00   08 00 16 00 0B 00 02 01  ................
00B0: 00 00 0D 00 1A 00 18 06   03 06 01 05 03 05 01 04  ................
00C0: 03 04 01 03 03 03 01 02   03 02 01 02 02 01 01     ...............
main, WRITE: TLSv1.2 Handshake, length = 207
[Raw write]: length = 212
0000: 16 03 03 00 CF 01 00 00   CB 03 03 58 74 C9 A1 45  ...........Xt..E
0010: D6 1C CC 89 CA 57 D9 F3   B2 69 AE F1 4C 54 29 DC  .....W...i..LT).
0020: 24 4B B9 73 AF 93 18 03   2B 9D DC 00 00 46 C0 23  $K.s....+....F.#
0030: C0 27 00 3C C0 25 C0 29   00 67 00 40 C0 09 C0 13  .'.<.%.).g.@....
0040: 00 2F C0 04 C0 0E 00 33   00 32 C0 2B C0 2F 00 9C  ./.....3.2.+./..
0050: C0 2D C0 31 00 9E 00 A2   C0 08 C0 12 00 0A C0 03  .-.1............
0060: C0 0D 00 16 00 13 C0 07   C0 11 00 05 C0 02 C0 0C  ................
0070: 00 04 00 FF 01 00 00 5C   00 0A 00 34 00 32 00 17  .......\...4.2..
0080: 00 01 00 03 00 13 00 15   00 06 00 07 00 09 00 0A  ................
0090: 00 18 00 0B 00 0C 00 19   00 0D 00 0E 00 0F 00 10  ................
00A0: 00 11 00 02 00 12 00 04   00 05 00 14 00 08 00 16  ................
00B0: 00 0B 00 02 01 00 00 0D   00 1A 00 18 06 03 06 01  ................
00C0: 05 03 05 01 04 03 04 01   03 03 03 01 02 03 02 01  ................
00D0: 02 02 01 01                                        ....
[Raw read]: length = 5
0000: 15 03 03 00 02                                     .....
[Raw read]: length = 2
0000: 02 50                                              .P
main, READ: TLSv1.2 Alert, length = 2
main, RECV TLSv1.2 ALERT:  fatal, internal_error
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLException: Received fatal alert: internal_error

EDIT 1: I got the following dependecies in the maven project - hoefully you now the HttpClient Version now...编辑 1:我在 Maven 项目中得到了以下依赖项 - 很高兴你现在是 HttpClient 版本......

<dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0.1</version>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.22.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.connectors</groupId>
        <artifactId>jersey-apache-connector</artifactId>
        <version>2.22.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
        <version>2.22.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.0</version>
    </dependency>

EDIT 2: Here is the whole log from AWS Lambda, if I execute the code in AWS Lambda.编辑 2:这是来自 AWS Lambda 的整个日志,如果我在 AWS Lambda 中执行代码。

*** ClientHello, TLSv1.2    
Cipher Suites: [TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA]
Compression Methods: { 0 }
Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
Extension server_name, server_name: [type=host_name (0), value=owapi.net]
Extension renegotiation_info, renegotiated_connection: <empty>
***
[write] MD5 and SHA1 hashes: len = 102
0000: 01 00 00 62 03 03 58 77 87 19 2B 1A 22 5B 19 D4 ...b..Xw..+."[..
0010: E3 22 6F B6 AE E9 C5 41 73 7A 24 0C 5A 63 E6 E2 ."o....Asz$.Zc..
0020: DA C5 81 1D 17 B7 00 00 06 00 9C 00 2F 00 35 01 ............/.5.
0030: 00 00 33 00 0D 00 18 00 16 06 03 06 01 05 03 05 ..3.............
0040: 01 04 03 04 01 03 03 03 01 02 03 02 01 02 02 00 ................
0050: 00 00 0E 00 0C 00 00 09 6F 77 61 70 69 2E 6E 65 ........owapi.ne
0060: 74 FF 01 00 01 00 t.....
AsyncHttpClient-2-1, WRITE: TLSv1.2 Handshake, length = 102
[Raw write]: length = 107
0000: 16 03 03 00 66 01 00 00 62 03 03 58 77 87 19 2B ....f...b..Xw..+
0010: 1A 22 5B 19 D4 E3 22 6F B6 AE E9 C5 41 73 7A 24 ."[..."o....Asz$
0020: 0C 5A 63 E6 E2 DA C5 81 1D 17 B7 00 00 06 00 9C .Zc.............
0030: 00 2F 00 35 01 00 00 33 00 0D 00 18 00 16 06 03 ./.5...3........
0040: 06 01 05 03 05 01 04 03 04 01 03 03 03 01 02 03 ................
0050: 02 01 02 02 00 00 00 0E 00 0C 00 00 09 6F 77 61 .............owa
0060: 70 69 2E 6E 65 74 FF 01 00 01 00 pi.net.....
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG DefaultChannelPool:231 - Closed 0 connections out of 0 in 0 ms
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dio.netty.recycler.maxCapacity.default: 32768
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dio.netty.recycler.maxSharedCapacityFactor: 2
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dio.netty.recycler.linkCapacity: 16
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dio.netty.recycler.ratio: 8
[Raw read]: length = 5
0000: 15 03 03 00 02 .....
[Raw read]: length = 2
0000: 02 28 .(
AsyncHttpClient-2-1, READ: TLSv1.2 Alert, length = 2
AsyncHttpClient-2-1, RECV TLSv1.2 ALERT: fatal, handshake_failure
AsyncHttpClient-2-1, fatal: engine already closed. Rethrowing javax.net.ssl.SSLException: Received fatal alert: handshake_failure
AsyncHttpClient-2-1, fatal: engine already closed. Rethrowing javax.net.ssl.SSLException: Received fatal alert: handshake_failure
AsyncHttpClient-2-1, called closeOutbound()
AsyncHttpClient-2-1, closeOutboundInternal()
AsyncHttpClient-2-1, SEND TLSv1.2 ALERT: warning, description = close_notify
AsyncHttpClient-2-1, WRITE: TLSv1.2 Alert, length = 2
AsyncHttpClient-2-1, called closeInbound()
AsyncHttpClient-2-1, fatal: engine already closed. Rethrowing javax.net.ssl.SSLException: Inbound closed before receiving peer's close_notify: possible truncation attack?
AsyncHttpClient-2-1, called closeOutbound()
AsyncHttpClient-2-1, closeOutboundInternal()
[Raw write]: length = 7
0000: 15 03 03 00 02 01 00 .......
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG NettyConnectListener:148 - Trying to recover from failing to connect channel [id: 0x3351b9a8, L:0.0.0.0/0.0.0.0:32982 ! R:owapi.net/104.24.101.166:443] with a retry value of true 
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG NettyConnectListener:158 - Failed to recover from connect exception: javax.net.ssl.SSLException: Received fatal alert: handshake_failure with channel [id: 0x3351b9a8, L:0.0.0.0/0.0.0.0:32982 ! R:owapi.net/104.24.101.166:443]
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> ERROR MasterOverwatchSpeechlet:186 - Fehler beim Lesen der Statistiken.
java.util.concurrent.ExecutionException: java.net.ConnectException: Received fatal alert: handshake_failure
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:160)
at de.mhproductions.ask.masteroverwatchskill.MasterOverwatchSpeechlet.getMasterOverwatchResponse(MasterOverwatchSpeechlet.java:158)
at de.mhproductions.ask.masteroverwatchskill.MasterOverwatchSpeechlet.onIntent(MasterOverwatchSpeechlet.java:70)
at com.amazon.speech.speechlet.SpeechletToSpeechletV2Adapter.onIntent(SpeechletToSpeechletV2Adapter.java:51)
at com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:218)
at com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)
at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)
at com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:1139)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:285)
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:94)
Caused by: java.net.ConnectException: Received fatal alert: handshake_failure
at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162)
at org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133)
at org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129)
at io.netty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:902)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:968)
... 18 more
java.util.concurrent.ExecutionException: java.net.ConnectException: Received fatal alert: handshake_failure
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:160)
at de.mhproductions.ask.masteroverwatchskill.MasterOverwatchSpeechlet.getMasterOverwatchResponse(MasterOverwatchSpeechlet.java:158)
at de.mhproductions.ask.masteroverwatchskill.MasterOverwatchSpeechlet.onIntent(MasterOverwatchSpeechlet.java:70)
at com.amazon.speech.speechlet.SpeechletToSpeechletV2Adapter.onIntent(SpeechletToSpeechletV2Adapter.java:51)
at com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:218)
at com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)
at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)
at com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:1139)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:285)
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:94)
Caused by: java.net.ConnectException: Received fatal alert: handshake_failure
at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162)
at org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133)
at org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129)
at io.netty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:902)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:968)
... 18 more
2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG AsyncCompletionHandler:71 - Received fatal alert: handshake_failure
java.net.ConnectException: Received fatal alert: handshake_failure
at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162)
at org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133)
at org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129)
at io.netty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:902)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:968)
... 18 more
2017-01-12 13:39:38 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG HttpHandler:157 - Unexpected I/O exception on channel [id: 0x3351b9a8, L:0.0.0.0/0.0.0.0:32982 ! R:owapi.net/104.24.101.166:443]
javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
2017-01-12 13:39:38 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG ChannelManager:370 - Closing Channel [id: 0x3351b9a8, L:0.0.0.0/0.0.0.0:32982 ! R:owapi.net/104.24.101.166:443] 
AsyncHttpClient-2-1, called closeOutbound()
AsyncHttpClient-2-1, closeOutboundInternal()

The issue seems to come down to the ECC cipher suite and lack of support in this version of the openjdk.问题似乎归结为ECC 密码套件和此版本的 openjdk 缺乏支持。 I was able to get it working by adding BouncyCastle to the project:我能够通过将 BouncyCastle 添加到项目中来使其工作:

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.56</version>
    </dependency>

And then adding the root, domain and SNI certs for owapi.net:然后为 owapi.net 添加根、域和 SNI 证书:

Security.addProvider(new BouncyCastleProvider());

// get cert
X509Certificate rootCert =
        (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(
                new BufferedInputStream(OwapiTestHandler.class.getResourceAsStream("/comodo-ecc-ca.crt"))
        );
X509Certificate domainCert =
        (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(
                new BufferedInputStream(OwapiTestHandler.class.getResourceAsStream("/comodo-ecc-domain-ca.crt"))
        );
X509Certificate sniCert =
        (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(
                new BufferedInputStream(OwapiTestHandler.class.getResourceAsStream("/sni235897.cloudflaressl.com.crt"))
        );

// add cert to keystore
KeyStore keystore = KeyStore.getInstance("PKCS12", BouncyCastleProvider.PROVIDER_NAME);
keystore.load(null, "".toCharArray());
keystore.setCertificateEntry("comodo-ecc-ca", rootCert);
keystore.setCertificateEntry("comodo-ecc-doman-ca", domainCert);
keystore.setCertificateEntry("cloudflair-sni", sniCert);

There's a fully working project on github here that includes all of the certs for owapi.net:这里有一个完整的 github 项目,其中包括 owapi.net 的所有证书:

https://github.com/codeengine1/owapi-test https://github.com/codeengine1/owapi-test/blob/master/src/main/java/com/codeengine/lambda/OwapiTestHandler.java https://github.com/codeengine1/owapi-test https://github.com/codeengine1/owapi-test/blob/master/src/main/java/com/codeengine/lambda/OwapiTestHandler.java

You most likely hit a JDK bug because you're running a version that isn't up-to-date.您很可能遇到 JDK 错误,因为您运行的版本不是最新的。 Upgrade to latest JDK8 (8112 atm).升级到最新的 JDK8 (8112 atm)。

First, test things locally, use java keytool to import ssl cert to cacerts.首先在本地进行测试,使用java keytool将ssl cert导入cacerts。 Then, add the cacert_new to same package of you java class:然后,将 cacert_new 添加到您的 java 类的同一个包中:

String pathKeyStore = com.amazonaws.samples.SaveUrl.class.getResource("cacerts_new").getPath();
System.setProperty("javax.net.ssl.trustStore", pathKeyStore);

package your code and deploy to aws lambda.打包您的代码并部署到 aws lambda。 should work the same way as local.应该以与本地相同的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM