1. Generate a Certificate
(1) Open Keytool.exe under the JDK's installation directory \bin\keytool.exe
On the command line, enter the following command:
Keytool-genkeypair-alias "Tomcat"-keyalg "RSA"-keystore "E:\tomcat.keystore"-validity 36500
The above command will produce a pair of asymmetric keys and self-signed certificates E:\tomcat.keystore
Note: "First and last name" should be the domain name, lost to the name, and the real run time domain name does not match, will be problematic
Here I enter the password is 123456, the domain name is tomcat for example, provinces and cities in Guangdong Shenzhen as an example
Configuring the Tomcat server
Locate the installation directory for the Tomcat server and locate the Server.xml file under Conf
Find the following code that has been commented:
<!--<connector port="8443"Protocol="http/1.1"Sslenabled="true"
maxthreads=" Max"Scheme="HTTPS"Secure="true"Clientauth="false"Sslprotocol="TLS"/>
-
Remove the comment and modify it to:
<connector port="8443"Protocol="http/1.1"Sslenabled="true"MaxThreads=" Max"Scheme="HTTPS"Secure="true"ClientAuth="false"Sslprotocol="TLS"Keystorefile="E:\tomcat.keystore"Keystorepass="123456"/>
On the Internet, the default port for the HTTP protocol is 443, and the default port for HTTPS is 443.
3.HTTP Automatic Jump Configuration
Configure Tomcat, open $CATALINA _home/conf/server.xml, and modify the following
<connector port="8080" protocol="http/1.1" ConnectionTimeout="20000" redirectport=" 8443" />
Revision changed to
<connector port= " 80 " protocol= " http/1.1 " connectiontimeout = " 20000 " Redirectport = " 443 " />
<!-- <connector port="8009" enablelookups="false" protocol="ajp/1.3" redirectport="8443" />-- >
Modified to:
<connector port="8009" enablelookups="false" protocol= " ajp/1.3 "redirectport="443 "/>
Add such a section to the </welcome-file-list> behind the Tomcat\conf\web.xml
<Login-config> <!--Authorization setting for SSL - <Auth-method>Client-cert</Auth-method> <Realm-name>Client Cert users-only Area</Realm-name> </Login-config> <Security-constraint> <!--Authorization setting for SSL - <web-resource-collection> <Web-resource-name>Ssl</Web-resource-name> <Url-pattern>/*</Url-pattern> </web-resource-collection> <User-data-constraint> <Transport-guarantee>Confidential</Transport-guarantee> </User-data-constraint> </Security-constraint>
HTTPS configuration and HTTP auto-jump configuration for Tomcat