Wednesday, March 25, 2009

How to implement SSL in tomcat6 and java 6?

How to make SSL(https) for web application?

Software required
jdk 6
tomcat 6

Follow the steps
Firsth check classpath set for java and in bin keytool.exe is the generator of the following

for all the question you can give your own answers and also for password give whatever you wish

C:\Documents and Settings\Administrator>keytool -genkey -alias tomcat -keyalg RSA

for password i have given as changeit(you can give whatever you wish but its should be reflected in server.xml configuration given below)
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: rajesh
What is the name of your organizational unit?
[Unknown]: vidyut
What is the name of your organization?
[Unknown]: vidyut
What is the name of your City or Locality?
[Unknown]: chennai
What is the name of your State or Province?
[Unknown]: Tamilnadu
What is the two-letter country code for this unit?
[Unknown]: TN
Is CN=rajesh, OU=vidyut, O=vidyut, L=chennai, ST=Tamilnadu, C=TN correct?
[no]: yes

Enter key password for (<)tomcat(>)* *=(please remove ( ))
(RETURN if same as keystore password):
Re-enter new password:

for the (<)tomcat(>)* no need of pass just press enter

You need to write the following in server.xml
server.xml will be in conf directory of tomcat installation and keystoreFile location depends on where you put your keystore file

(opening html tag)Connector protocol="org.apache.coyote.http11.Http11Protocol"
port="8443" minSpareThreads="5" maxSpareThreads="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="C:/IPS/.metadata/.me_tcat/conf/.keystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS"(closing html tag)

and disable the 8080 connector code.now you run your application you will get the url with https
if not try it with typing in browser itself.
if you get error like below




you need to do the following things

Secure connection Failed

1.click Or you can add an exception…

2 you will two buttons "get me out of here" and "add Exception"

3.click add exception

4. then click get certificate

5. click confirm security exception

Now everything will be fine

1 comment:

Anonymous said...

Hey,

I keep coming to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]rajeshkannanforindia.blogspot.com is filled with quality info. Frankly speaking we really do not pay attention towards our health. Let me show you one truth. Research shows that closely 60% of all U.S. adults are either fat or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these individuals, you're not alone. Its true that we all can't be like Brad Pitt, Angelina Jolie, Megan Fox, and have sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? Quick weight loss can be achived with little effort. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am webmaster of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for fast weight loss.