springboot应用程序中的Nio2Endpoint.Nio2SocketWrapper.getSslSupport异常

时间:2019-09-20 11:28:00

标签: java spring-boot ssl tomcat ssl-certificate

我为spring boot应用程序实现了自签名的ssl证书。尽管结果如预期般来临,但出现以下异常。 使用Springboot:2.1.8和Tomcat:9.0.24

我尝试将协议从“ org.apache.coyote.http11.Http11NioProtocol”更改为“ org.apache.coyote.http11.Http11Nio2Protocol”。但是仍然有例外。

抛出的异常。

@Bean
    public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
        TomcatServletWebServerFactory tomcatServletWebServerFactory = new TomcatServletWebServerFactory();
        tomcatServletWebServerFactory.setProtocol("org.apache.coyote.http11.Http11Nio2Protocol");
        return tomcatServletWebServerFactory;
    }
    at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper.getSslSupport(Nio2Endpoint.java:1581) ~[tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853) ~[tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1685) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1087) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.SecureNio2Channel$HandshakeReadCompletionHandler.failed(SecureNio2Channel.java:104) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.SecureNio2Channel$HandshakeReadCompletionHandler.completed(SecureNio2Channel.java:97) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at org.apache.tomcat.util.net.SecureNio2Channel$HandshakeReadCompletionHandler.completed(SecureNio2Channel.java:92) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) [na:1.8.0_201]
    at sun.nio.ch.Invoker$2.run(Invoker.java:218) [na:1.8.0_201]
    at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.24.jar:9.0.24]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

1 个答案:

答案 0 :(得分:1)

那是Tomcat 9.0.24中的known bug。当您尝试在启用TLS的连接器上使用纯文本时会触发该事件。该错误已在最近发布的9.0.26中修复。