I have Tomcat 9.0.12 and Java JDK/JRE 1.8.0_191. I'm trying to configure SSL/TLS. I've changed my server.xml file like this:
<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" />
My certificate file is *.pfx format. I run tomcat server via command line with startup.bat command. But i got an error like this (in my 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)
...
when i try to connect http://localhost:443 i get ERR_CONNECTION_REFUSED which i added to below.
ERR_CONNECTION_REFUSED:
In Tomcat 9.0.x get rid of the below exceptions by updating the protocol attribute value in the Connector element of server.xml file.
Exceptions:
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
Exception Syntax:
<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"
/>
In the above Connector element syntax update the protocol attribute value
From
protocol="org.apache.coyote.http11.Http11Protocol"
To
protocol="org.apache.coyote.http11.Http11NioProtocol"
Note: In order to use an explicit protocol rather than rely on the auto-switching mechanism one of the below values may be used, choose as per your requirement
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.