java.net.ConnectException:handshake alert:unrecognized_name

时间:2018-03-21 06:48:07

标签: java ssl asynchttpclient

我正在使用库 org.asynchttpclient:async-http-client:2.4.0 来同时抓取不同主机的多个网址。我在网站https://www.westcommunitycu.org/index.shtml遇到此问题时,图书馆无法获得回复。错误为java.net.ConnectException: handshake alert: unrecognized_name

堆栈追踪:

Caused by: java.net.ConnectException: handshake alert:  unrecognized_name
at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:182)
at org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:153)
at org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:512)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:505)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:484)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:425)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
at io.netty.handler.ssl.SslHandler.handleUnwrapThrowable(SslHandler.java:1183)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1165)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1202)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1414)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:945)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name
at sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1446)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1791)
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$SslEngineType$3.unwrap(SslHandler.java:292)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1256)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1159)
... 19 more

我已经读过,在java中禁用sni(设置-Djsse.enableSNIExtension = false)将解决问题并且它确实修复了它。但是,当SNI被禁用时,另一个网站https://www.cityftmyers.com出现错误java.net.ConnectException: https://www.cityftmyers.com:443

堆栈追踪:

Caused by: java.net.ConnectException: https://www.cityftmyers.com:443
at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:182)
at org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:153)
at org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:512)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:505)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:484)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:425)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
at io.netty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1543)
at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1529)
at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1005)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1409)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:927)
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)

引起:java.nio.channels.ClosedChannelException     at io.netty.handler.ssl.SslHandler.channelInactive(...)(未知来源)

我如何支持这两个实例?我尝试使用AHC配置进行挖掘,但我找不到与SNI相关的配置,因此我可以在某些主机上启用/禁用sni。

0 个答案:

没有答案