lanproxy icon indicating copy to clipboard operation
lanproxy copied to clipboard

用go客户端怎么通过ssl连接java服务端

Open xinsmile opened this issue 7 years ago • 6 comments

客户端错误 2018/11/12 13:43:12 Error dialing x509: certificate signed by unknown authority

服务端错误 2018-11-12 13:43:12,886 ERROR [org.fengfei.lanproxy.server.handlers.ServerChannelHandler] - io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: bad_certificate at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:418) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) at java.lang.Thread.run(Thread.java:748) Caused by: javax.net.ssl.SSLException: Received fatal alert: bad_certificate 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:1098) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:970) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:904) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387) ... 12 more

xinsmile avatar Nov 12 '18 05:11 xinsmile

server.ssl.needsClientAuth=false 这个配置忽略,配置成false

ffay avatar Nov 13 '18 01:11 ffay

这个本来就是配成false。 这个go启动的证书是和java客户端的test.jks一样吗,还是其他不同的证书

xinsmile avatar Nov 13 '18 01:11 xinsmile

暂时去掉 -cer 参数吧

ffay avatar Nov 13 '18 05:11 ffay

去掉 -cer ,那这还是ssl连接吗,这样是不是跟普通的连接一样

xinsmile avatar Nov 14 '18 11:11 xinsmile

那想要用ssl连接,要怎么弄?

xinsmile avatar Nov 15 '18 00:11 xinsmile

有这个参数 -ssl true 就是ssl连接,只是证书验证部分忽略了,数据还是加密传输的

ffay avatar Nov 15 '18 01:11 ffay