Step 1: generate the. keystore File
% Java_home % keytool-genkey-alias tomcat-keyalg RSA-keystore my. keystore
Step 2: Modify the Tomcat server. xml file
Copy the generated tomcat. keystore file to the conf folder of Tomcat, which is in the same path as the server. xml file,
<Connector
Port = "8443" maxthreads = "200"
Scheme = "HTTPS" secure = "true" sslenabled = "true"
Keystorefile = "./CONF/mytomcat. keystore" keystorepass = "123qew"
Clientauth = "false" sslprotocol = "TLS"/>
Among them, 123qwe is the password set when generating my. keystore. If you only want to Use https access, You Need To comment out the original 8080 window listener.
<! -- Connector Port = "8080" protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443"/-->
Recently, we found that the same configuration is as follows ]:
<Connector Port = "8080" protocol = "HTTP/1.1" sslenabled = "true"
Maxthreads = "150" Scheme = "HTTPS" secure = "true"
Clientauth = "false" sslprotocol = "TLS" keystorefile = "./CONF/tomcat. keystore" keystorepass = "123qwe"/>
The solution is normal under tomcat-7.0.27 and abnormal under tomcat-7.0.23.
<Connector Port = "8080" protocol = "org. Apache. Coyote. http11.http11protocol" sslenabled = "true"
Maxthreads = "150" Scheme = "HTTPS" secure = "true"
Clientauth = "false" sslprotocol = "TLS" keystorefile = "./CONF/tomcat. keystore" keystorepass = "123qwe"/>
The reason for the introduction of APR is that the connector configuration has a subtle relationship with whether APR is supported. The following connector configuration will go wrong when APR is supported!
The configuration in Tomcat-6 and tomcat-7.0.23 enables the connector instance to load the org. Apache. Coyote. http11.http11aprprotocol protocol processor, while http11aprprotocol does not have the keystorefile attribute. Therefore, an error is reported during startup! Therefore, the recommended connector configuration: Protocol = "org. Apache. Coyote. http11.http11protocol"
Or protocol = "org. Apache. Coyote. http11.http11aprprotocol.