< one, >,tomcat7 configuring HTTPS
1. Generate KeyStore file and export certificate
Download our generate exported certificate Tomcat.cer and import this certificate to our client host
Access test binding domain name---because I was testing the qrui.com domain name does not actually exist (please bind the host hosts by yourself)
Original content
1Windows: 1.1 Generate KeyStore File and export certificate Open console: Run:%java_home%\bin\keytool-genkey-alias tomcat-keyalg RSA Follow the required step-by-step input information, When asked about your country code, enter CN. When you enter your password, use it here: Changeit the last step when you enter it, go directly to it. The specific records are as follows: C:\users\administrator>%java_home%\bin\keytool-genkey-alias tomcat-keyalg RSA input keystore Password: Enter the new password again: What is your first and last name? [Unknown]: Tuhao What is your organizational unit name? [Unknown]: Tuhaojia What is your organization name? [Unknown]: Fnic What is the name of your city or region? [Unknown]: Didu What is your state/province name? [Unknown]: Didu What is the two-letter country/region code for this unit? [Unknown]: Cncn=tuhao, Ou=tuhaojia, O=fnic, L=didu, St=didu, c=cn correct? [No]: y input<Tomcat>Key password (if same as KeyStore password, press ENTER): Here you have to press ENTER directly. In the current directory, a:. keystore file is created and copied to the Tomcat bin directory. From the console into the Tomcat bin directory, the native environment is the:d:\tomcat7\bin> export certificate file: D:\tomcat7\bin>keytool-selfcert-alias tomcat-keystore. KeyStore Enter the KeyStore password: (here is the Changeit that was entered when the certificate was generated) D:\tomcat7\bin>keytool-export-alias Tomcat-keystore. KeyStore- Storepass changeit-rfc-file tomcat.cer stored in file<Tomcat.cer>the Tomcat.cer certificate file is generated under d:\tomcat7\bin> at this time. Send the file to the consumer, have them install the certificate, and install the certificate in the Trusted Root Certification authorities area. Specific procedures can refer to the Ministry of Railways 12306.cn website Certificate installation procedures. They are the same as the same. 1.2 Configure Tomcat to open $catalina_base/conf/server.xml find the "SSL http/1.1 Connector" piece, uncomment it and change it to:<ConnectorPort= "443"Protocol= "http/1.1"sslenabled= "true"MaxThreads= "Max"Scheme= "https"Secure= "true"Keystorefile= "Bin/.keystore"Keystorepass= "Changeit"ClientAuth= "false"Sslprotocol= "TLS" />Please note that I have changed the Tomcat port to 80, and the corresponding HTTPS port I have changed to 443 (that is, the default HTTPS port). To modify the host file of the Windows machine, add a line (my machine's IP is 192.168.68.75): 192.168.68.75 Tuhao then reboot Tomcat and use https://tuhao/to visit the site to verify it. Next, you will demonstrate HTTPS configuration for Tomcat under Linux. 2.linux settings: 2.1 Generate KeyStore File and export certificate This step is similar to operating under Windows, except that the environment variable is referenced differently, and this time we specify the directory where the generated file is stored: [Root@localhost ~]# $JAVA _ Home/bin/keytool-genkey-alias tomcat-keyalg Rsa-keystore/usr/local/tomcat/bin/.keystore Enter keystore password: Enter the new password again: What is your first and last name? [Unknown]: tuhao.com What is your organizational unit name? [Unknown]: Tuhaojia What is your organization name? [Unknown]: Fnic What is the name of your city or region? [Unknown]: Didu What is the name of your state or province? [Unknown]: Didu What is the two-letter country code for this unit [Unknown]: cncn=tuhao.com, Ou=tuhaojia, O=fnic, L=didu, St=didu, c=cn correct? [No]: y input<Tomcat>the master password (if the same as the KeyStore password, press ENTER): Right here to hit enter [Root@localhost ~]# cd/usr/local/tomcat/bin/[root@localhost bin]# Keytool- Selfcert-alias tomcat-keystore. KeyStore Enter keystore password: [root@localhost bin]# keytool-export-alias tomcat-keystore. Key Store-storepass Changeit-rfc-file tomcat.cer The certificate saved in the file<Tomcat.cer>Copy the/usr/local/tomcat/bin/tomcat.cer to local. 2.2 Configuring Tomcat: As with Windows, I copied the part of Windows directly: Open $catalina_base/conf/server.xml to find the "SSL http/1.1 Connector" piece, Uncomment and change it to:<ConnectorPort= "443"Protocol= "http/1.1"sslenabled= "true"MaxThreads= "Max"Scheme= "https"Secure= "true"Keystorefile= "Bin/.keystore"Keystorepass= "Changeit"ClientAuth= "false"Sslprotocol= "TLS" />Please note that I have changed the Tomcat port to 80, and the corresponding HTTPS port I have changed to 443 (that is, the default HTTPS port). Next is to set up the firewall, I tried to increase the TCP port 443, allow access, but the outside still can not access the server's HTTPS, simply I will iptables service stopped, so that it can. Verify that the configuration was successful: Restart Tomcat, modify the Windows machine's host file, add a line (the IP of the Linux machine is 192.168.68.74): 192.168.68.74 Tuhao.com then install Tomcat.cer, note that you must install it in the trusted root Certification authorities area. Access via browser: https://tuhao.com/can see that HTTPS is considered trustworthy. Summary: When the certificate is generated, "What is your first and last name" must pay attention to enter your IP, machine name, domain name, in short, you want to visit your website through https://xx in the future, here will fill in XX. Otherwise, there will be a certificate that is not trusted by the prompt.
View Code
< two,>
TOMCAT,TOMCAT7 Configuring HTTPS