Deploying SSL Certificate on Tomcat
Download the Keystore Explorer from here as per your Operating System.
Install the Keystore Explorer.
Open the Keystore Explorer.
Click on “Create a new KeyStore” and then select “JKS”.
Now we will Generate Key Pair, by clicking on icon from below the screen.
While Generating Key Pair, select RSA from the dialog and click on OK.
A new dialog will appear, now click on in front of Name.
Provide information in the dialog below, you can also provide domain name in place of IP address in Common Name and then click on OK.
After providing all the information in step 7, it will look like this, verify details and click on OK.
Now provide Alias name to Key Pair generated and then click on OK.
Now provide New Password and Confirm Password for the Key Pair.
Now your Key Pair is generated successfully.
Now you can Save the Key Pair as .JKS file on the local disk.
Now Generate Certificate Signing Request (CSR) file to create a certificate file by right-clicking on generated Key Pair.
Save CSR file to local disk.
Now provide this CSR file to Certificate Authority (CA) to create an SSL Certificate.
Now we will create a Self Signed SSL Certificate.
To create a Self Signed SSL Certificate, right-click on generated Key Pair, click on Export, and then Export Certificate Chain.
Save the certificate (.cer) file on the local disk by clicking on Export.
Now we will Import the SSL Certificate (CA-signed or Self-Signed certificate) to Key Pair to be used in Tomcat.
To Import the SSL Certificate, click on from the header and select the certificate file provided by CA or Self-Signed Certificate.
Now the certificate is imported to the Key Pair and Save the Key Pair(.jks file).
Also, Import the certificate file to "cacerts" located at %JAVA_HOME%\jre\lib\security\cacerts. If asked for a password, provide “changeit”.
To Import the SSL Certificate in cacerts, click on from the header and select the certificate file provided by CA or Self-Signed Certificate.
Provide Alias name while importing the certificate, Now the certificate is imported to cacerts.
Now, we will configure Tomcat to use SSL Certificate.
Configure SSL/TLS Connector in TOMCAT_DIR/conf/server.xml, Copy and paste the below connector to server.xml and replace the value of keyAlias, keystoreFile, keystorePass with yours.
<Connector port="5443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" SSLEnabled="true" clientAuth="false" sslProtocol="SSL" keyAlias="myapp" keystoreFile="D:/SSL Certificate/myapp.jks" keystorePass="admin" sslEnabledProtocols="TLSv1.2"/>
Save the changes to the server.xml file.
Start/Restart the Tomcat server. Access the Tomcat server from browser with HTTPS (https://localhost:5443)
Congratulations! You've successfully installed your SSL certificate.
Very well explained... It was of great help... Please share the SSL configuration for Keycloak as well.
ReplyDelete