Eclipse WTP: How do I enable SSL on Tomcat?

谁说我不能喝 提交于 2019-11-29 20:16:51

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

Nikhil R

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

I figured it out. When you first create a new server in the Servers view by right clicking in it and selecting New > Server. Eclipse WTP takes your existing server.xml file from the tomcat installation and creates the new server.xml file for your project using the original as a template.

If you modify the original server.xml with the configuration you need BEFORE creating a new server in eclipse you will retain those settings.

It's too bad eclipse doesn't allow adding these types of configurations after the fact.

Provided you have the certificate(s) and keystore as mentioned earlier in this post, I found the following solution to configuring Eclipse to be able to communicate with SSL-enabled servers. When using the Tomcat configuration tool, you must add entries to the "Java" tab, "Java Options" text box, as follows:

-Dbusinessobjects.orb.oci.protocol=ssl
-Dcertdir=c:\ssl
-DtrustedCert=c:\ssl\cacert.der
-DsslCert=c:\ssl\servercert.der
-DsslKey=c:\ssl\server.key
-Dpassphrase=c:\ssl\passphrase.txt

Similarly in Eclipse, right click on the server name in the Project Explorer window, click Profile As | Profile Configurations | Arguments, and append the same options listed above to the "VM Arguments:" text box. That should allow you to run and debug programs againse SSL-enabled servers.

Eclipse "VM Arguments:" text box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!