1> Use jdk to generate the key file
[Plain] view plaincopyprint?
Keytool-genkey-alias tomcat-keyalg RSA-keypass changeit-storepass changeit-keystore server. keystore-validity 3600
2> go to tomcat/config/server. xml and find
<! -- Define a ssl http/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR,
Connector shocould be using the OpenSSL style configuration
Described in the APR documentation -->
<! --
<Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true"
MaxThreads = "150" scheme = "https" secure = "true"
ClientAuth = "false" sslProtocol = "TLS"/>
-->
Remove comments and add key file configuration
<Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true"
MaxThreads = "150" scheme = "https" secure = "true"
ClientAuth = "false" sslProtocol = "TLS"
KeystoreFile = "server. keystore"
KeystorePass = "changeit"/>
After saving and restarting tomcat, you can access tomcat through https: // ip: 8443/webproject (your web project) over https. Port 8443 is used above. If port 443 is changed to port, because 443 is the default https Port
Force https access
Add the following configuration after </welcome-file-list> in 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>
Enter http: // ip: 8080/webproject to force redirect to https: // ip: 8443/webproject.
If the https port is set to another port, remember to change the http transfer port together.
Www.2cto.com
<Connector port = "8080" protocol = "HTTP/1.1"
ConnectionTimeout = "20000"
RedirectPort = "<span style =" color: # FF0000; "> 8443 </span>" URIEncoding = "UTF-8"/>
Column of the author ChinFeng