Tomcat 9 SSL/TLS -无法初始化组件错误

vpfxa7rd  于 2022-11-14  发布在  其他
关注(0)|答案(3)|浏览(344)

我有Tomcat 9.0.12和Java JDK/JRE 1.8.0_191。我正在尝试配置SSL/TLS。我将server.xml文件更改为如下所示:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
               keystoreFile="C:\my_certificate.pfx"
               keystorePass="my_password" keystoreType="PKCS12" />

我的证书文件是 *.pfx。我通过命令行用startup.bat命令运行tomcat服务器。但是我得到了一个类似这样的错误(在我的catalina.log中):

...
05-Nov-2018 16:33:57.080 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Nov-2018 16:33:57.190 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Nov-2018 16:33:57.205 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[org.apache.coyote.http11.Http11Protocol-443]]
 org.apache.catalina.LifecycleException: Protocol handler instantiation failed
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:904)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:533)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:852)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:656)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:306)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:491)
...

当我尝试连接http://localhost:443时,我得到ERR_CONNECTION_REFUSED,我将其添加到下面。
错误_连接_拒绝:

zzoitvuj

zzoitvuj1#

Tomcat 9.0.x中,通过更新*server.xml*文件的Connector元素中的protocol属性值,消除以下异常。

例外情况:

27-Mar-2020 08:06:45.726 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[org.apache.coyote.http11.Http11Protocol-auto-null]]
org.apache.catalina.LifecycleException: Protocol handler instantiation failed

27-Mar-2020 08:06:44.929 SEVERE [main] org.apache.catalina.connector.Connector.<init> Protocol handler instantiation failed
java.lang.ClassNotFoundException: org.apache.coyote.http11.Http11Protocol

例外语法:

<Connector port="9443" 
    protocol="org.apache.coyote.http11.Http11Protocol"
    maxThreads="200" 
    SSLEnabled="true" 
    scheme="https" 
    secure="true"
    clientAuth="want" 
    sslProtocol="TLS" 
    connectionTimeout="20000" 
    keystoreFile="D:\\MYAPP\\DINESH_LOMTE\\dlomte_keystore.jks" 
    keystorePass="cardinal" 
    keystoreType="JKS"
    truststoreFile="D:\\MYAPP\\DINESH_LOMTE\\dlomte_truststore.jks" 
    truststorePass="cardinal" 
    truststoreType="JKS"
/>

在上面的Connector元素语法中,更新protocol属性值
起始日期

protocol="org.apache.coyote.http11.Http11Protocol"

结束日期

protocol="org.apache.coyote.http11.Http11NioProtocol"

**注意:**为了使用显式协议而不是依赖于自动切换机制,可以使用以下值之一,请根据您得要求进行选择

org.apache.coyote.http11.Http11NioProtocol - non blocking Java NIO connector
org.apache.coyote.http11.Http11Nio2Protocol - non blocking Java NIO2 connector
org.apache.coyote.http11.Http11AprProtocol - the APR/native connector.
hivapdat

hivapdat2#

我遇到了同样的问题。它开始初始化一个非IO阻塞连接器

05-Nov-2018 16:33:57.080 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

但您的配置建议使用io阻塞连接器

Http11Protocol

因此,也许您可以尝试使用其他连接器代替。在我的情况下,将Http11Protocol更改为Http11NioProtocol有助于修复此错误。

xuo3flqw

xuo3flqw3#

对于tomcat 9,将8443连接器的协议改为HTTP1.1。〈Connector port=“8443”protocol=“HTTP/1.1

相关问题