問題
在調整 Tomcat 10 要啟用 TLS 時,有參考網路上的設定,
在建立好 keystore 後,就將設定直貼到 server.xml 之中,如下,
1 | <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" |
結果在啟動 tomcat 時,就噴 Protocol handler initialization failed 及 **Caused by: java.lang.IllegalArgumentException: No SSLHostConfig element was found with the hostName [default] to match the defaultSSLHostConfigName for the connector [https-openssl-nio-8443]**的錯誤,如下,
org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1018)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:549)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:999)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.startup.Catalina.load(Catalina.java:747)
at org.apache.catalina.startup.Catalina.load(Catalina.java:769)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:307)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:477)
Caused by: java.lang.IllegalArgumentException: No SSLHostConfig element was found with the hostName [default] to match the >defaultSSLHostConfigName for the connector [https-openssl-nio-8443]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:75)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:207)
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1256)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1269)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:622)
at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:77)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1016)
解決
查看 tomcat 預設的 設定值似乎跟貼上去的內容不同,
於是改用 tomcat 的內容來調整,
1 | <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" |
重新啟動 tomcat 就正常運作了,
開啟 Browser ,連到 https://localhost:8443
也可以正常看到 tomcat 首頁