Steps to create your own self signed certificate with java plugin working

You need two tools that comes with your jdk which are keytool and jarsigner.

Steps explain below in detail. Don't use netscape signtool, it will NEVER work!

* keytool -genkey -keyalg rsa -alias tstkey -keypass 2br2h2m -dname "cn=Test Object Signing Certificate, o=AI Khalil, ou=Java Products, c=AU"

cn = Certificate name

o = organistation

ou = organistation unit

c = country (first two letters)

If don't put the -dname, you can fill it line by line.

The -keypass has to be verify at the end, and you have to wait for it to create the rsa signing keys.

On NT by default it will put the alias information at D:\WINNT\Profiles\Administrator (if log in as administrator) with the default file called ".keystore". Windows 98 etc, don't know, search for .keystore

file. When you update it, check for the timestamp change and you know if you at the right spot.

You can store your alias information via the -storepass option to your current directory you work on, if you don't want to update the default .keystore file?

The .keystore contains a list of alias so you don't have to do this process again and again.

Another tip if you want your certificate encryption validity to be more than the default one month is simply

add the -validity <valDays>, after the -genkey option, to make your certificate usage for encryption to last much longer.

Note: You MUST use the -keyalg rsa because for starters the rsa encyption alogorthim is supported on ALL browsers instead of the default DSA and the other one SHA. Java plugins must work with the RSA algorthim when signing applets, else you will get all sorts of weird errors :)

Do not use signtool because thats a browser dependant solution!! Java plugin is supposed to work via running it owns jre instead of the browser JVM. So if you going to use netscape signtool, it starts to become a mess! ie certificate will install, but applet won't start and give you funny security exception errors :)

* keytool -export -alias tstkey -file MyTestCert.crt

It will read the alias information in the .keystore information picking up the rsa private/public keys info and

create your self sign certificate. You can double click this certificate to install it? But don't think this step is needed but maybe for IE? Someone else can check that part.

If you make a mistake with the alias, simply keytool -delete -v -alias <your alias key>

If not in default .keystore file, then simply keytool -delete -v -alias <your alias key> -keystore <your keystore filename>

* Put your classes in your jar file, my example is tst.jar.

* jarsigner tst.jar tstkey

Sign your testing jar file with your alias key that supports the RSA encryption alogorthim.

* jarsigner -verify -verbose -certs tst.jar

Check that its been verified.

The last step is the most tricky one. Its to do with having your own CA (Certified Authority) so you don't

have to fork out money straight away to buy a Verisign or Twarte certificate. The CA listing as you see in

netscape browsers under security/signers, is NOT where the plugin looks at. The plugin looks at a file called

CACERTS. Another confusion is that the cacerts file is stored in your jre/lib/security AND also at your

JavaSoft/Jre/<Java version>/lib/security. When you install the Java plugin for the first time in uses your

JavaSoft folder and its the cacerts file that has to be updated you add your own CA, because thats where

the plugin look at, NOT THE BROWSER. Everything about plugin is never to do with the browser!! :)

* keytool -import -file MyTestCert.crt -alias tstkey -keystore "D:\Program Files\JavaSoft\JRE\1.3.1\lib\security/cacerts"

Off course point to your own cacerts file destination.

Password to change it, is "changeit"

Before you do this step make a copy of it in its own directory in case you do something silly.

This example will add a CA with alias of my key called "tstkey" and store to my example destination.

* keytool -list -v -keystore "E:/jdk/jdk1.3/jre/lib/security/cacerts"

List to see if another CA is added with your alias key.

Your html, using Netscape embed and Internet explorer object tags to point to the java plugin,

your own self sign applet certificate should work

Cheers

Abraham Khalil

[4512 byte] By [akhalil100] at [2007-9-26 2:01:22]
# 1
Check out: http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/toplevelcontainers/japplet/jappletsec/signjappcontrol.htmlCheers,Joris
vdbjoris at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...
# 2

I follow Signed Applet in Plugin, and it's working on my computer. Thanks

But When I open my applet from another computer on network, why it does not work ..?

How to make this applet working at another computer without change the policy file ..?

thanks in advance,

Anom

gusti_anom at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...
# 3

> I follow Signed Applet in Plugin, and it's working on

> my computer. Thanks

>

> But When I open my applet from another computer on

> network, why it does not work ..?

>

> How to make this applet working at another computer

> without change the policy file ..?

>

>

> thanks in advance,

>

> Anom

You must install the certificate on that computers plugin. Can this be done from the web? can anyone suggest a batch file or otherwise that could do this for end users?

I want a way for end users to accept my cert as Root or at least trust my cert so I dont have to buy one. I am not worried about my users refusing to accept my cert. just how do I make it easy for them? IE you can just click the cert from a link, but that installs for IE, and not the plugin where it needs to be.

dnoyeB at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...
# 4
This page suggests a means of importing a certificate into cacerts: http://home.iSTAR.ca/~neutron/ImportCA/. Haven't tried it; haven't heard of a nicer way.
kent_haidl at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...
# 5
Thanks heaps for the very straight forward and simple solutions, It should be the White paper on this Subject!No other doccos around explain how to get the plug in to use your own certficates as a CA.Well done!
mann0087 at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...
# 6
> Check out:> > http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/tolevelcontainers/japplet/jappletsec/signjappcontrol.html> > > Cheers,> Joristhanks for the link. this helped me a lot.
srikanth105 at 2007-6-29 8:41:36 > top of Java-index,Security,Signed Applets...