Configuration steps: 1. Obtain the SSL certificate; 2. Configure the SSL certificate; 3. Edit the Tomcat configuration file; 4. Restart Tomcat. Detailed introduction: 1. You need to obtain an SSL certificate, either a self-signed certificate or a valid SSL certificate from a certification agency (such as Let's Encrypt); 2. Place the obtained SSL certificate and private key files on the server and ensure that these files Located in a safe location, only users with sufficient permissions can access; 3. Edit Tomcat configuration files, etc.
Operating system for this tutorial: Windows 10 system, Dell G3 computer.
To enable HTTPS on Tomcat, you need to perform the following steps:
1. Obtain an SSL certificate:
First, you need to obtain an SSL certificate . You can self-sign a certificate or obtain a valid SSL certificate from a certification authority such as Let’s Encrypt.
2. Configure the SSL certificate:
Place the obtained SSL certificate and private key file on the server. Usually, the certificate file is in .crt or .pem format, and the private key file is in .key format. Make sure these files are in a secure location that only users with sufficient permissions can access.
3. Edit the Tomcat configuration file:
Find the conf/server.xml file in the Tomcat installation directory and make the following configuration changes:
Find the Connector tag, which is usually the part that listens for HTTP requests, port 8080. Add a new Connector in the Connector tag for HTTPS connection. The example is as follows:
<Connector port="443" protocol="HTTP/1.1" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" keystoreFile="/path/to/your/keystore.jks" keystorePass="your_keystore_password" clientAuth="false" sslProtocol="TLS"/>
port="443": Specify the port number for HTTPS connection.
SSLEnabled="true": Enable SSL.
keystoreFile: Specify the path to the SSL certificate.
keystorePass: Specify the password for the SSL certificate.
clientAuth="false": Specifies whether client authentication is required, generally set to false.
sslProtocol="TLS": Specify the SSL protocol version.
Replace /path/to/your/keystore.jks with your actual SSL certificate path and file name, and replace your_keystore_password with the certificate password.
4. Restart Tomcat:
Save and close the server.xml file. Then restart the Tomcat server for the changes to take effect. You can stop and start Tomcat using ./bin/shutdown.sh and ./bin/startup.sh or similar commands.
Once you complete the above steps, Tomcat should be configured to use HTTPS. You can test whether the HTTPS connection is working properly by visiting https://your_domain.com (replace it with your actual domain name) via your browser.
The above is the detailed content of How to configure https in tomcat. For more information, please follow other related articles on the PHP Chinese website!