To enable tomcat to use ssl, you must first configure its https. The configuration method is as follows:
1. Create a key
Enter cmd and enter
- keytool -genkey -alias tomcat -keystore mykeystore -keyalg RSA -validity 2000
Follow the promptsEnter Password: Changeit,
What is your first name and last name? (Enter the domain name here. Enter localhost in the local test)
Just enter the remaining questions.
This will generate a mykeystore file under the C: \ Documents ents and Settings \ Administrator directory.
- keytool -export -alias tomcat -keystore mykeystore -file server.crt
The password is also entered changeit. If the operation is successful, a file of server. crt will be generated under the directory, and then execute
- keytool -import -alias tomcat -file server.crt -keystore %JAVA_HOME%/jre/lib/security/cacerts
After the password is entered, the key is created after you confirm that the password is correct.
2. Configure tomcat
Open conf/server. xml in the tomcat installation directory and add the following code:
- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
- maxThreads="150" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS"
- keystoreFile="d:/mykeystore "
- keystorePass="changeit"/>
The keystoreFile in the code can be written as an absolute path. Note that the protocol in the Code has different tomcat configurations in different versions. For details, refer:
Tomcat 4.1.34 Configuration
- <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
- port="8443" enableLookups="true" scheme="https" secure="true"
- acceptCount="100"
- useURIValidationHack="false" disableUploadTimeout="true"
- clientAuth="false" sslProtocol="TLS"
- keystoreFile="server.keystore"
- keystorePass="changeit"/>
Tomcat 5.5.9 Configuration
- <Connector port="8443" maxHttpHeaderSize="8192"
- maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
- enableLookups="false" disableUploadTimeout="true"
- acceptCount="100" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS"
- keystoreFile="server.keystore"
- keystorePass="changeit"/>
Tomcat 5.5.20/5.5.34 Configuration
- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
- maxThreads="150" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS"
- keystoreFile="d:/mykeystore "
- keystorePass="changeit"/>
Configure tomcat 6.0
- <Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
- port="8443" minSpareThreads="5" maxSpareThreads="75"
- enableLookups="true" disableUploadTimeout="true"
- acceptCount="100" maxThreads="200"
- scheme="https" secure="true" SSLEnabled="true"
- clientAuth="false" sslProtocol="TLS"
- keystoreFile="D:/tools/apache-tomcat-6.0.10/server.keystore"
- keystorePass="changeit"/>
For tomcat5.5.20 and tomcat5.5.34 versions, if no
- protocol="org.apache.coyote.http11.Http11Protocol"
Or write it
- protocol="HTTP/1.1 "
The following errors will occur:
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1403303233-0.jpg "/>
Now, we have configured the https for tomcat. Enter
Https: // localhost: 8443/
If the access succeeds, the configuration is successful. The configuration of the cas server and client is described below.
This article from "Qiao Lei's blog learning progress" blog, please be sure to keep this source http://sucre.blog.51cto.com/1084905/683560