Configure SSL Certificate in Tomcat
SSL Stands for Secure Socket Layer. In web SSL certificates plays Key role while passing sensitive information to the server ie, username, password,credit card details etc.
In order to configure SSL Certificate in web or application server , we need to purchase SSL Certificate from CA’s (Certificate Authorities) .
But we can create dummy SSL certificates for development purpose by using a tool given by java called , that tool name is keytool , it comes along with Java installation.
Procedure to create SSL Certificate:
Set java path in environment variables, so that we can use keytool command in any where. Open command prompt and type
keytool -genkey -alias tomcat -keyalg RSA -keystore mycert.cert
It will ask several questions like Enter keystore password, Organizational unite and etc. Enter all the details. It creates mycert.cert SSL file in home directory.
Add Created Self Signed Certificate to Tomcat 7
Go to Tomcat installation installation directory and navigate to conf folder , open server.xml and try to find below code.
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />
Above code is commented by default in server.xml , we need to un comment that code and add created SSL certificate details.
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="C:\mycert.cert" keystorePass="your password" clientAuth="false" sslProtocol="TLS" />
Restart Tomcat and type this url in browser https://localhost:8443. We can see a lock symbol in address bar preceded by https