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

编程入门 行业动态 更新时间:2024-10-09 11:22:56
本文介绍了如何在AWS Lambda中调用SSL安全的REST服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以对 owapi/api/v3/u/<Playername>-<BattleTagNumber>/stats 通过带有AWS Lambda的JAX RS REST客户端,如果是这样,我必须使用Java SSL设置什么?目前,我正在执行以下操作:

Is it possible to do an REST call to owapi/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? Currently I do the following:

System.setProperty("javax.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.ssl.SSLException: Received fatal alert: internal_error

使用该javax.debug协议:

With that javax.debug protocol:

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.ssl.SSLException: Received fatal alert: internal_error

编辑1: 我在Maven项目中遇到了以下依赖-头,您现在有了HttpClient版本...

EDIT 1: I got the following dependecies in the maven project - hoefully you now the HttpClient Version now...

<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>

编辑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] 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..... 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 - -Dioty.recycler.maxCapacity.default: 32768 2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dioty.recycler.maxSharedCapacityFactor: 2 2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dioty.recycler.linkCapacity: 16 2017-01-12 13:39:37 <8b2d050a-d8cc-11e6-8262-5ddb1e7af2d2> DEBUG Recycler:76 - -Dioty.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.ssl.SSLException: Received fatal alert: handshake_failure AsyncHttpClient-2-1, fatal: engine already closed. Rethrowing javax.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.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/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.ssl.SSLException: Received fatal alert: handshake_failure with channel [id: 0x3351b9a8, L:0.0.0.0/0.0.0.0:32982 ! R:owapi/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.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.asynchttpclientty.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.ConnectException: Received fatal alert: handshake_failure at org.asynchttpclientty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162) at org.asynchttpclientty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133) at org.asynchttpclientty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26) at ioty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) at ioty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507) at ioty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486) at ioty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427) at ioty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129) at ioty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063) at ioty.handler.ssl.SslHandler.decode(SslHandler.java:902) at ioty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) at ioty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346) at ioty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) at ioty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at ioty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652) at ioty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575) at ioty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489) at ioty.channel.nio.NioEventLoop.run(NioEventLoop.java:451) at ioty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) at ioty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) at java.lang.Thread.run(Thread.java:745) Caused by: javax.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.ssl.SSLEngine.unwrap(SSLEngine.java:624) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:968) ... 18 more java.util.concurrent.ExecutionException: java.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.asynchttpclientty.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.ConnectException: Received fatal alert: handshake_failure at org.asynchttpclientty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162) at org.asynchttpclientty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133) at org.asynchttpclientty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26) at ioty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) at ioty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507) at ioty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486) at ioty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427) at ioty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129) at ioty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063) at ioty.handler.ssl.SslHandler.decode(SslHandler.java:902) at ioty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) at ioty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346) at ioty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) at ioty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at ioty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652) at ioty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575) at ioty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489) at ioty.channel.nio.NioEventLoop.run(NioEventLoop.java:451) at ioty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) at ioty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) at java.lang.Thread.run(Thread.java:745) Caused by: javax.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.ssl.SSLEngine.unwrap(SSLEngine.java:624) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097) at ioty.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.ConnectException: Received fatal alert: handshake_failure at org.asynchttpclientty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162) at org.asynchttpclientty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:133) at org.asynchttpclientty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26) at ioty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) at ioty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507) at ioty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486) at ioty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427) at ioty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:129) at ioty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1238) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1233) at ioty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1208) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1063) at ioty.handler.ssl.SslHandler.decode(SslHandler.java:902) at ioty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) at ioty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346) at ioty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) at ioty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at ioty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652) at ioty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575) at ioty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489) at ioty.channel.nio.NioEventLoop.run(NioEventLoop.java:451) at ioty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) at ioty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) at java.lang.Thread.run(Thread.java:745) Caused by: javax.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.ssl.SSLEngine.unwrap(SSLEngine.java:624) at ioty.handler.ssl.SslHandler.unwrap(SslHandler.java:1097) at ioty.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/104.24.101.166:443] javax.ssl.SSLException: Received fatal alert: handshake_failure at ioty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) at ioty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346) at ioty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367) at ioty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353) at ioty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) at ioty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at ioty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652) at ioty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575) at ioty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489) at ioty.channel.nio.NioEventLoop.run(NioEventLoop.java:451) at ioty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) at ioty.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/104.24.101.166:443] AsyncHttpClient-2-1, called closeOutbound() AsyncHttpClient-2-1, closeOutboundInternal()

推荐答案

问题似乎归结于 ECC密码套件,并且在此版本的openjdk中缺少支持。我可以通过将BouncyCastle添加到项目中来使其工作:

The issue seems to come down to the ECC cipher suite and lack of support in this version of the openjdk. I was able to get it working by adding BouncyCastle to the project:

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

然后为owapi添加根,域和SNI证书:

And then adding the root, domain and SNI certs for owapi:

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.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:

There's a fully working project on github here that includes all of the certs for owapi:

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

更多推荐

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

本文发布于:2023-11-28 06:06:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   AWS   Lambda   SSL   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!