Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse WTP: How do I enable SSL on Tomcat?

Eclipse WTP creates its own server.xml file which it places in some folder which configures the tomcat instance you are running for your web project. If you double click on the server in the servers list you get a nice screen which makes it simple to configure some aspects of the server.xml file.

How do I configure a new connection to allow SSL connections on port 8443. Everytime I edit the server.xml file manually, eclipse overwrites my changes with the settings it has stored in the server properties page of the configuration and it seems there is no way to add a new connector from the interface that eclipse provides.

Is this possible? Here is the connector I want to add:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"     maxThreads="150" scheme="https" secure="true"     keystoreFile="D:\apache-tomcat-6.0.18\keystore\key.ssl" keystorePass="pass"     clientAuth="false" sslProtocol="TLS" /> 
like image 582
Peter D Avatar asked Jun 04 '09 17:06

Peter D


People also ask

How do I change Tomcat settings in Eclipse?

For configuring the tomcat server in eclipse IDE, click on servers tab at the bottom side of the IDE -> right click on blank area -> New -> Servers -> choose tomcat then its version -> next -> click on Browse button -> select the apache tomcat root folder previous to bin -> next -> addAll -> Finish.

How do I force Tomcat to https?

To force tomcat to redirect and revert all requested HTTP traffic to HTTPS, You need to edit the 2 Tomcat configuration files. That's it Restart the Tomcat and test you will see all pages should redirect to https.


2 Answers

If you've already created the server, you can edit the server.xml template it copies. If you use the project explorer, It is under Other Projects->Servers->Tomcat Server Name->server.xml

like image 167
yincrash Avatar answered Oct 11 '22 12:10

yincrash


Here is how you get it to work:
Create the keystore:

keytool -genkey -alias tomcat -keypass mypassword -keystore keystore.jks -storepass mypassword -keyalg RSA -validity 360 -keysize 2048 

(Follow through the prompts and fill in the information)
It should then save a keystore.key file to your home directory.
To get it to work in eclipse :

<Connector port="8443" SSLEnabled="true"         maxThreads="150" minSpareThreads="25" maxSpareThreads="75"         enableLookups="true" disableUploadTimeout="true"         acceptCount="100" debug="0" scheme="https" secure="true"         clientAuth="false" sslProtocol="TLSv1"         keystoreFile="/home/myUsername/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/keystore.key"         keystorePass="mypassword" /> 

The above path for keystoreFile is something you absolutely need to get right for this to work. When eclipse uses a workspace metadata location to run tomcat, it copies over some files into a path that looks like the above. On OS X this would be:

/Users/<username>/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/keystore.key 

Hope that helps.

For More Reference : SSL/TLS Configuration HOW-TO in Apache Tomcat 7

like image 21
Nikhil R Avatar answered Oct 11 '22 13:10

Nikhil R