How to sign an applet (and get it to work)
How To Sign a Java Applet
The purpose of this document is to document the steps required to sign and use an
applet using a self-signed cert or CA authorized in the JDK 1.3 plugin.
The original 9 steps of this process were posted by user irene67 on suns message forum:
http://forums.java.sun.com/thread.jsp?forum=63&thread=132769
--begin irene67's original message --
These steps describe the creation of a self-signed applet. This is useful for testing purposes. For use of public reachable applets, there will be needed a "real" certificate issued by an authority like VeriSign or Thawte. (See step 10 - no user will import and trust a self-signed applet from an unkown developer).
The applet needs to run in the plugin, as only the plugin is platform- and browser-independent. And without this indepence, it makes no sense to use java...
1. Create your code for the applet as usual.
It is not necessary to set any permissions or use security managers in
the code.
2. Install JDK 1.3
Path for use of the following commands: [jdk 1.3 path]\bin\
(commands are keytool, jar, jarsigner)
Password for the keystore is *any* password. Only Sun knows why...
perhaps ;-)
3. Generate key: keytool -genkey -keyalg rsa -alias tstkey
Enter keystore password: *******
What is your first and last name?
[Unknown]: Your Name
What is the name of your organizational unit?
[Unknown]: YourUnit
What is the name of your organization?
[Unknown]: YourOrg
What is the name of your City or Locality?
[Unknown]: YourCity
What is the name of your State or Province?
[Unknown]: YS
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
correct?
[no]: yes
(wait...)
Enter key password for tstkey
(RETURN if same as keystore password):
(press [enter])
4. Export key: keytool -export -alias tstkey -file tstcert.crt
Enter keystore password: *******
Certificate stored in file tstcert.crt
5. Create JAR: jar cvf tst.jar tst.class
Add all classes used in your project by typing the classnames in the
same line.
added manifest
adding: tst.class(in = 849) (out= 536)(deflated 36%)
6. Verify JAR: jar tvf tst.jar
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
68 Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/MANIFEST.MF
849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
7. Sign JAR: jarsigner tst.jar tstkey
Enter Passphrase for keystore: *******
8. Verifiy Signing: jarsigner -verify -verbose -certs tst.jar
130 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/MANIFEST.MF
183 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.SF
920 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.RSA
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
X.509, CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
(tstkey)
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
9. Create HTML-File for use of the Applet by the Sun Plugin 1.3
(recommended to use HTML Converter Version 1.3)
10. (Omitted See Below)
--end irene67's original message --
To make the plug-in work for any browser you have two options with the JDK 1.3 plugin.
1) Is to export a cert request using the key tool and send it to a CA verification source like verisign.
When the reponse comes back, import it into the keystore overwriting the original cert for the generated key.
To export request:
keytool -certreg -alias tstkey -file tstcert.req
To import response:
keytool -import -trustcacerts -alias tstkey -file careply.crt
An applet signed with a cert that has been verified by a CA source will automatically be recognized by the plugin.
2) For development or otherwise, you may want to just use your self-signed certificate.
In that case, the JDK 1.3 plugin will recognize all certs that have a root cert located in the JDK 1.3 cacerts keystore.
This means you can import your test certificate into this keystore and have the plugin recognize your jars when you sign them.
To import self-signed certificate into the cacerts keystore, change directory to where the JDK plugin key store is located.
For JDK 1.3.0_02: C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security
For JDK 1.3.1: C:\Program Files\JavaSoft\JRE\1.3.1\lib\security
Import your self-signed cert into the cacerts keystore:
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
(the password is literally 'changeit')
Now, regardless of which method you use, the applet should be recognized as coming from a signed jar.The user can choose to activate it if he / she chooses. If your applet uses classes from multiple jars, for example Apache's Xerce's parser, you will need to sign those jars as well to allow them to execute in the client's brower. Otherwise, only the classes coming from the signed jar will work with the java.security.AllPermission setting and all other classes from unsigned jars will run in the sandbox.
NOTE: Unless otherwise specified by the -keystore command in all keytool and jarsigner operations, the keystore file used is named '.keystore' in the user's home directory.
The first time any keystore is accessed (including the default) it will be created and secured with the first password given by the user. There is no way to figure out the password if you forget it, but you can delete the default file and recreate it if necessary. For most operations, using the -keystore command is safer to keep from cluttering or messing up your default keystore.
This worked beautifully for me!!! Thanks!!!
However, I have a follow up question.
I had to change dev machines and need to now continue development on the new box but I can't sign the jar file correctly on the new machine.
I copied my tstcert.crt file to the new machine and tried:
keytool -import -file tstcert.cer -alias tstkey -storepass ****
It successfully imported the cert into the default keystore.
But when I now try to sign the jar I have an error:
jarsigner myjar.jar tstkey
jarsigner: certificate not found for: tstkey
But it seems like it's there:
keytool -list -alias tstkey
tstkey, Tue Oct 02 15:28:04 PDT 2001, trustedCertEntry,
Certificate fingerprint (MD5): A1:62:AD:E7:0A:CD:AE:03:A9:1A:56:FB:B1:47:FC:25
Any ideas?
To sign a jar you need both a public key and a private key. The certificate you imported is effectively the public key. If you create a new keystore and import the certificate you will still be missing the private key.
This is why you need to generate a key first, export a request to a CA verification source, and import the response. The response effectively overwrites your public key and keeps your private key the same.
If you need to use your key to sign jars on another machine, copy the keystore file instead of just the cert and it should work for you.
You can tell the difference in the keystore listing between a cert and a key by looking for the keyword 'keyEntry'
Public Certificates are marked as: trustedCertEntry
Full keys that can be used to sign are: keyEntry
Hope this helps...
Thanks again! It's working after I moved my keystore file over.:)-Nakul
I am wondering...whether i need to ask my users to change their policy files if i want my applet access their local drives? I have already setup a self-signed certificate and imported it to my users' machine.
It seems to me that self-signed applets still can't access local drives unless the client change their policy file. Is this correct?
Many thanks in advance.
If the jar the applet comes from is signed, the user should see the screen allowing them to grant all permissions to the applet.
If the user 'oks' the applet, all rights are given to the applet. However, if the applet uses classes in more than one jar, all the jars must be signed for all the classes to have full permissions; otherwise, classes in unsigned jars will be will be restricted by the security manager.
Policy files should not be necessary. When all the applet's jars are signed correctly, and the user grants the applet rights to run, the applet will have all permissions granted to it.
Nice tips indeed.
One query: My applet is self signed. It is signed by jdk 1.1.7. At the client side, it is verified using JDK 1.1.7 also. I have 3 questions in this scenario:
1. Is there some way to avoid installing the plug-in at the client?
2. At the client side, the user of this intranet application needs to manually import the certificate in his keystore using javakey -import. Is there a possibility of the applet handling this itself i.e. when the applet is downloaded, the certificate gets imported into the client's keystore automatically?
3. Is there any problem with permanently using self signed certificates in an intranet application?
Thanks, hope these answers help you...
1) Without using the plug-in, you need to use browser based security. Both Netscape and IE have different ways of granting security rights and have different requirements of certificates. You would need to get different tools from Microsoft and Netscape (similar to the security tools that come with the jdk like keytool) to generate those keys. The plug-in allows the ability to sign an applet that will work in both browsers. The plug-in is the easiest thing to use and guarantees the JVM environment is compatible with sun, but if this app is for an intranet you can probably deal with a few browser specific quirks. Here is a site that explains more about browser specific security:
http://www.suitable.com/Doc_CodeSigning.shtml
2) JDK 1.1 was fundamentally flawed in that it can't distribute certificates. There are a couple of solutions (hacks) around this problem people have come up with.
This link will explain more about how to distribute your 1.1 certificates:
http://www.suitable.com/CodeSigningSignPlug.shtml#top
3) There is no problem using self-signed certificates in an intranet as long as every user on the intranet has there keystore updated with your certificate. (see the url in response 2 for more information)
i'm well had been step 9 that i nothing meet the matter
but step 10 error occuring............
i'm Linux platfom and i have Client directory access case by browser
===================================================================
step 10.
Keytool -certreg -alias tstkey -file tstcert.req excute after
enter keystore password : xxxxx ;
after..... occuring the matter....
To import response:
keytool -import -trustcacerts -alias tstkey -file careply.crt
====================================================================>
keytool error : java.io.FileNotFoundException: careply.crt (No such file or directory)
because i not Certificate browse..........
please!! help me..
Try putting the careply.crt file in the directory in which you are working. Else, give the full path of the careply.crt file in the command.
First of all, sorry for my English (since im spanish...)
I've followed the 10 steps 4 sign an applet for the plug in 1.2
but when I open the HTML locally or from a HTTP server, (IE5.5, W98), the plugin 1.2 loads
and start loading classes, but it pop up this exception:
( Im translating the following from spanish, so it may differ from
english version of plugin :)
>>>Java Module security adv.<<<<
"Its imposible to verify the cert. Code will be used as not signed"
And a exception stack for:
"java.security.cert.CertificateException: Unable to verify the cert. with root CA"
I hope anyone know how can i solve this...
Thanks.
First of all, sorry for my English (since im spanish...)
I've followed the 10 steps 4 sign an applet for the plug in 1.2
but when I open the HTML locally or from a HTTP server, (IE5.5, W98), the plugin 1.2 loads
and start loading classes, but it pop up this exception:
( Im translating the following from spanish, so it may differ from
english version of plugin :)
>>>Java Module security adv.<<<<
"Its imposible to verify the cert. Code will be used as not signed"
And a exception stack for:
"java.security.cert.CertificateException: Unable to verify the cert. with root CA"
I hope anyone know how can i solve this...
Thanks.
frodoSonOfDrogo,
No problem, I think I know what your problem is.
The plug-in needs to have the certificate corresponding to the key you signed your jar with in it's trusted keystore. Any jar signed with a certificate that is verified by Verisign or Thawte will automatically be recognized because Verisign and Thawte are considered to be root CAs (Certificate Authorities).
For example, you authenticate your code is yours by signing it, but the plug-in does not know who you are. Therefore, if another entity such as Verisign verifies you are who you say you are, the plug-in will recognize you.
If you want to self-certify your applet, you need to make the plug-in trust your signature like it would a Root CA. The JDK 1.3 plug-in has a keystore in which it hold certificates to all root CAs. If your certificate was added to it, the plug-in would recognize you.
However, JDK 1.1 & JDK 1.2 are a little different then JDK 1.3. To make the JDK 1.2 plug-in work you could try what I read on another website: http://java.sun.com/products/plugin/1.2/docs/netscape.html
My understanding is the JDK 1.2 plug-in verifies Root CA certificates are valid based on what your browser determines is a root CA. Therefore, if you export your cert to a file and import it with explorer, MS Internet Explorer should now consider your signature to be a root CA and your applet should work in the plug-in the next time you restart your browser.
Here is another site that specifically deals with the JDK 1.2 plug-in and how to get it to work with a self-signed certificate: http://java.sun.com/security/signExample12
Hope this helps...
Hi!Thank you very much! Finally, a very good article covering all steps involved in signing and getting your signed applet to work.RegardsJohan
Hi,
I did followed your list of instructions. It worked well and now I am getting the question to let my applet work. But after I got a Security Exception, access denied. I try to use my applet to read and write a FoxPro table from the Active Desktop. I also tried to modify the Policy file, but the result is the same. Do you have any ideas what I did wrong?
In the JDK 1.3 plugin, if you get the popup and grant the applet the right to execute it should be running with the equivalent security policy of AllPermissions. That means the applet can do anything it wants including reading and writing to a database or a file...
So my first question would be which plug-in are you using? But, you might be caught on the problem in which every jar your applet uses must be signed with the same signature used to sign your applet. When your applet is granted the right to run, all code signed with the same signature is granted AllPermissions as well. If you load classes from additional jars or from your codebase and they are not signed the same as your applet, they will be limited by the Security Manager.
I would recommend highly to avoid any modification to any policy files because users on the Internet either won't want or won't know how to do the same change to get your applet to work.If all your jars are signed and recognized you shouldn't have any issues.
Good luck...
Hi,
Thanks for the reply. I am using 1.3.1 plugin. I did the whole stuff again, signed the applet, exported the signature, imported into the cacert keystore, run the applet, then I got the same message! Then I started to look into the code! I am using a special driver to access Visual FoxPro table, this is a third party driver. I did changed into ODBC driver, the message is gone, my applet appears, but I got other messages now, about the resultset ... something to fix it for today :)
Yes, you are right, the policy file modification is a pain in the ***, thanks to god, this small application will be used ony by a small group of developers
I just released an appli that helps signing either with DSA or RSA encryption.
You may get it for free at
. windows:
http://www.xlreader.com/download/stl10ea/InstData/Windows/NoVM/istl10ea.exe
. Unix and Linux:
http://www.xlreader.com/download/stl10ea/InstData/Unix/Others/istl10ea.bin
Robert
=====
robert@xlreader.com
XL-Reader Project - Secured online documentation solutions
www.xlreader.com
=====
Problems with signed applets, JavaScript and privileged calls in Netscape 6.x?
I've been trying to get a signed Sun 1.3+ applet to work with Netscape 6.x for the last week or so. I get it signed, etc., but can't get privileged calls to work when an applet method is called from JavaScript. If I made the same call from the init() or start() method, it works fine (just trying to delete a file for test purposes). The exact same scenario works fine using IE6 with the Sun plugin (the one that replaces the MS JVM).
I've reported this to mozilla.org (http://bugzilla.mozilla.org/show_bug.cgi?id=109067), but there is no solution that Im aware of at this time.
As a work-around, I was able to launch a thread in the start() method which I then can use to make privileged calls via an applet method call from JavaScript. The method call does a notify/wait to talk with the thread started by start().
This is not a desirable solution, but luckily already fit into what I was doing.
That's interesting...Most of my development is coded and tested for IE, so I haven't had too many problems with Netscape...Thanks for the tip.
ncoleman1,Just like to say thanks for the tip. Every thing works great.
With all the back and forth messages Im a little confused...
I've used the Java Plugin ages ago, but today is there any need for manual, command-line acceptace from a user to run a signed applet?
The above question applies to both scenarios - 'self-signed' as well as 'CA signed'.
I dont want the 'acceptance' of the certificate to be so complex that users dont want to use it.
Thanks.
If anyone is interested in the problem I stated above, there is more information now at: http://bugzilla.mozilla.org/show_bug.cgi?id=109067
hi,
Does the method work for only the machine of which the cetificate was imported, or will ALL the net users on ANY machine will be able to accept/decline this signed applet?
(I'm referring to option 2 of step 10)
if not, is there a way to make an applet signed (with out paying for it) for all the net users?
tanks,
aner
Unfortunatly, all users would have to import your certificate if you create a self-signed applet. This is to prevent potential security concerns of users running applets that are not recognized as secure by organizations.
It is possible to manipulate certificates through the Java API, you might be able to write an applet that requests security rights specifically or runs outside the plug-in to set up the certificate.
Hope this helps...
Hi everyone,
I am using the Java Plugin 1.3.1_01. I followed all the 10 steps but I still got the error message, "Unable to verify certificate with ROOT CA" while I have already imported my selfcert to the c:\program files\javasoft\jre\1.3.1_01\lib\security\cacerts. I have been stuck in this problem for a very long time. Please, help me if anyone knows how to solve it. Thanks!
Hugo
I'm not exactly sure what could be wrong, but I might be able to point you in the right direction.
The message you are receiving means the plug-in regonizes the applet is signed, but the certificate that corresponds to the signature cannot be verified for some reason. If the certificate is imported into the cacerts keystore, as you have said, then there shouldn't be a problem.
The only thing I can think of is the plug-in resets when the browser is totally shut down and Duke disappears off of the icon tray. If you haven't already, I would restart the browser to make sure the plug-in refreshes the Root CA certificates from its keystore.
Good luck, sorry I couldn't be more help...
Hi all
I have the problem same to Hugo.
I've follow the right step but still can't work.
The error message is still coming out.
I'm wonder the problem is from the version of Java Plug_In. I'll try to make sure it.
Ncoleman, can you tell me the version of SDK and Java Plug_In you use ?
Thanks
Fuzen
Hi Ncoleman,
Thank you very much for your suggestion but I have even rebooted my computer for several times. I also supposed that it should work, but to my disappointment, it hasn't. I really don't why Java gave up the way of verifying certs by the browser. It is good cuz everyone can install a root cert easily while they do not need to know how to use the keytool. And now, their new mechanism put a burden on the developers, especially for whom designing programs for intranet.
Hugo
I'm having the same problem as gariman. I'd like to know how much time it takes to get the "careply.crt" back and where is it supposed to appear?Thanks in advance!
Hi,
Sorry I will specify my problem to make it more clear!
I went throught the 9 steps but when I type the last command:
================================================================
keytool -import -trustcacerts -alias tstkey -file careply.crt
================================================================
I get the error:
================================================================
keytool error: java.io.FileNotFoundException: careply.crt
================================================================
When I search for the file on my hard drive, I don't find it!
Could you help me, this is the very first time I try to sign an Applet!!!
Thanks in advance
I've now signed my applet (I think), but when I run it from IE6.0, I don't get any popups asking me if my applet can run. I have self signed the applet, but it doesn't work properly. Could it be because I cannot use System.getproperty("user.name") even if I've signed my applet, or is there another reson?
Hi Ncoleman,
I have an applet that needs to access a text file from the folder where the jar file is present.
First it did not work. So, I changed the policy file to give persmissions to read, write and execute the files. With this it worked well with the appletviewer, but not with the IE browser.
Then I came across your discussion, the most detailed description and resourceful. I really appreciate you taking time answering it in detail.
I have followed the 9 steps successfully for signing an applet.
Then from the folder where the tstcert.crt is residing, I executed the last step
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
After all the details, it said
Certificate was added to keystore.
Then I tried to access the file from the browser.
It did not work!
I saw the Content tab in the Internet options of IE.
In it, I used the certificates window and imported the tstcert.crt file into the list.
Now I tried to read the file, this worked well!!
But then my problem is not solved yet...
I want this applet to put up in the geocities.com
So I uploaded this jar file and the text files to access, into the folder in geocities.
When I tried the same applet through the geocities website, it did not work!!!
So my questions are ...
1. why the applet did not work in the browser after completing the 10 step?
2. How did it work when I imported the certificate thru internet options? What happened then?
3. How to make the applet work through the geocities site?
Please take time to answwer my questions. I really need all these answers. I hope you will not disappoint me.
Thank you in Advance
Sapna
This worked fine for me but I have a follow up question!
I have my self-signed applet with jdk1.2.2. It works fine in a conventional PC but I am trying to get it work in a PDA - iPAQ Compaq H3870 running Pocket PC 2002 and Jeode Virtual Machine 1.9. The applet opens a connection to a remote URL so it must be signed. When I run the applet in the applet viewer I obtain a security exception ...
java/lang/ExceptionInInitializer ...
java.security.AccessControlException
I've just read a lot of posts and messages but find no answer ... only one regarding the java.security file under de lib directory of my PDA ... please could anybody help me ?
Thank you very much,
Alberto.
Hey Alberto,Can u please tell me how to make the applet run on the browser?Walk me through the stepsI hope you have read my post above, please tell me whatelse I have to do to make it workTIASapna
Hello all,
This is an awesome thread! With regards to signed applets:
If I have an applet (A) that is signed, and within it, a custom class loader (extension of URLClassLoader) which loads the classes of applet (B) from a signed jar, I can launch applet (B) with full previllages (i.e. java.security.AllPermissions). As long as my first applet (A) is signed, and the user accepts that, giving applet (B) full access shouldn't be a problem right? I guess I can place more security by checking to see if the signature of applet B is okay, programmatically? I haven't found a way to either:
1. Pass down the current permissions of applet (A) to applet (B).
OR
2. Check the signature of applet (B) programmatically.
Any insight would be much appreciated. Thanks in advance.
Hello all,
This is an awesome thread! With regards to signed applets:
If I have an applet (A) that is signed, and within it, a custom class loader (extension of URLClassLoader) which loads the classes of applet (B) from a signed jar, I can launch applet (B) with full previllages (i.e. java.security.AllPermissions). As long as my first applet (A) is signed, and the user accepts that, giving applet (B) full access shouldn't be a problem right? I guess I can place more security by checking to see if the signature of applet B is okay, programmatically? I haven't found a way to either:
1. Pass down the current permissions of applet (A) to applet (B).
OR
2. Check the signature of applet (B) programmatically.
Any insight would be much appreciated. Thanks in advance.
HI, I signed my applet but how do you make the browser to accept the sign?How can I pop the certificate so it can be accepted by the users?Thanks!
This is really a great summary of what do to - but it doesn't work for me:
I followed all steps (signing applet, importing cert etc) and the applet runs absolutely great with IE and JavaPlugIn 1.4.0 - the popup comes and I can accept the cert. The applet can read and write files without problems.
Then I tried Netscape 6.2 with PlugIn 1.4.0 - and it does not work. I get the popup to accept the signed applet and then the applet can read files but as soon as it tries to write a file, a SecurityException occurs.
There are several posts in different forums having the same problem - but I saw no answer.
The only solution I currrently have is to write a policy file for Netscape :(
And in addition, I have to grant all code bases access, so something like:
grant codeBase "http://myserver/directory/-" { ... }
does not work.
Does anyone see what is wrong? Or is it a problem with Netscape and PlugIn 1.4.0?
Thanks and regards
Carsten
Hi,
I want to know, after i follow all the steps listed. Do the client side still need to edit the policy stuff in order to grant the permission manually?
Coz after i made the applet with that cert, when i load the html with that applet, it throw some permission exceptions.
so, anyone know why?
Thanks!!
Vincy
Ok, I can confirm now, that you don't need a policy file or edit it if you have followed the steps above!
There is one exception and that's why it didn't work for me:
If you are using Netscape/Mozilla with a signed applet and invoke the applet via JavaScript, then the method invoked by JavaScript has not the rights anymore. This is because Netscape does not trust the JavaScript and there it doesn't trust the applet anymore.
There is another thread in this forum dealing with exactly this case. It's not a bug of Netscape/Mozilla and you can add some extra lines in your applet and then you don't need a policy file in these cases, too.
So finally everything is working here!
Thanks for all your help!
Carsten
HELP!!!
I've searched high and low and I know someone has thought of protecting their client's systems from allowing them to grant full permission to signed applets but WITHOUT changing the client's policy file.
Is there a way to have a grant permission box come up when you want to write/read to a specific file and have permissions granted to write/read to that file only? Then if you need to do so again with another file, the grant box comes up again for permissions to do that action?
This way the client/user's machine is protected from FREE roaming to all of their files and they can still grant permission for me to write/read file x or y WITHOUT changing their policy files.
Any clues would be appreciated greatly
Ziegeler,Can you tell us where that other thread is?
hi i am getting anerror for this command:keytool -certreg -alias tstkey -file tstcert.reqerror:Illegal option: -certreg pls help
Hi,
I am having a problem for making the signed applet to work....
I've followed Irene67's steps to generate the signed jar's...As I am just doing this test for development purposes, I've done a
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
But even after this step...when i open my html page , i am not able to see the security window that should be popping up...
please help me out with this
thanks
raj.
Hi ncoleman,
I have done exactly what you have mentioned.
But still I get a security exception in IE6.0 while
creating a directory through applet.
I have used a .jar file for my applet to work. Do I need to use
.cab file for IE?
Apart from this I have also taken permission in the init() of the
applet.
SO what went wrong?
Thanks,
Sujoy
It is really a very nice effort regarding the signing of applets.But the problem I am facing is that after completing the "The 10 steps" successfully, I am unable to access a local file through IE6.0...I have even tried through an entry in Certificates option of the IE6.0....The message I get is of successful import of the certificate but it does not show up in the area.
I am on Win XP and using jdk1.4 plug-in and IE 6.0....Any help will be highly appreciated..
I was wondering about that as well, and think I found the other thread, in which the only interesting thing was:
http://bugzilla.mozilla.org/show_bug.cgi?id=109067
The thread was http://forum.java.sun.com/thread.jsp?forum=63&thread=183585
I did what the document said and in my applet where I used to have :
executer = new Thread (AThreadedWorkerApplet.this);
executer.setPriority(Thread.NORM_PRIORITY);
executer.start();
I now have:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// privileged code goes here
executer = new Thread (AThreadedWorkerApplet.this);
executer.setPriority(Thread.NORM_PRIORITY);
executer.start();
return null;
}
});
so it was a small change indeed (only it won't run without VM anymore, I will fix that in the morning ;-))
Hope this helps. By the way, we use a polling mechanism in our applets, without relying on JSOBject or whatever and the applets run practically verywhere (mac, unix, windows and on IE and netscape when at least liveconnect is supported).
Hi,
I learn that clealy on ur help, however, I met a problem during my work.
Can I specify my problem following:
I went throught the 9 steps but when I type the last command:
keytool -import -keystore cacerts -alias duke -file mycert.crt
I get the error:
================================================================
keytool error: java.io.FileNotFoundException: cacerts (Access is denied)================================================================
I think that's the system admins not allow me to modify it since i do a project in college to use signed applet technology, is that right?
Ishould contact them and ask for permission or I have any other solution? Can you show me some idea?
Thanks in advance
Dear ncoleman1,
I have trying to handle a MSAccess Database with DSN using an applet.
I have followed you solve, but at the runtime I am getting an error stating "SQLException No suitable Driver Found".
I have tried the same code with a console based program, it does not create any problem, but when I tried it with appletviewer or browser that problem occur.
import java.sql.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="test.class" width=200 height=200>
</applet>
**/
public class test extends Applet implements ActionListener
{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String str=null;
TextArea ta;
public void init()
{
ta= new TextArea(10,30);
add(ta);
Button b1 = new Button(">>");
add(b1);
b1.addActionListener(this);
ta.setText("Initialization...\n");
}
public void actionPerformed(ActionEvent ae)
{
ta.appendText("Inside actionPerformed\n");
try
{
ta.appendText("Inside try block\n");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
ta.appendText("Class loaded\n");
/********** upto this point it works fine **************/
con=DriverManager.getConnection("jdbc:odbc:dbcon","","");
ta.appendText("Connection created\n");
stmt=con.createStatement();
ta.appendText("Statement created\n");
rs=stmt.executeQuery("select * from student");
ta.appendText("Resultset created\n");
while(rs.next())
{
str=str+rs.getString(1)+" ";
str=str+rs.getString(2)+" "+"\n";
}
ta.appendText(str);
con.close();
stmt.close();
rs.close();
}catch(ClassNotFoundException cnfe){System.out.println("Class Not found "+cnfe.getMessage());}
catch(SQLException sqle){System.out.println("SQL Exception "+sqle.getMessage());}
catch(Exception e){ta.setText(e.getMessage());}
}
}
Please suggest me what should I do
Hello every one,
i write sign applet and it function in any machine where
there is installed jdk.
Now i need to know how i can run this applet in machines where
there no installed jdk
This work of applet is to execute a process on the client for
example notepad.exe.
thanks
Has anyone tried signing for IE,Netscape4.x and
Netscape 6+?
I think IE isnt really a problem; the classes
can simply be packaged in a cab file and other
browsers will ignore them.
I ve tried signing using Netscapes signtool
and Sun s jarsigner, but then neither will work.
Also, I cant import my certificates into Netscape
4 s database and have them recognized as code
signing certificates.
can anyone send me the signed Applet code so that i can have an idea of how to develop my owen signed code. if anyone can send pls send it to akilasivam@hotmail.com id.thanks in advance.regards,s.akila
> How To Sign a Java Applet
>
> The purpose of this document is to document the steps
> required to sign and use an
> applet using a self-signed cert or CA authorized in
> the JDK 1.3 plugin.
>
> The original 9 steps of this process were posted by
> user irene67 on suns message forum:
> http://forums.java.sun.com/thread.jsp?forum=63&thread
> =132769
>
> --begin irene67's original message --
> These steps describe the creation of a self-signed
> applet. This is useful for testing purposes. For use
> of public reachable applets, there will be needed a
> "real" certificate issued by an authority like
> VeriSign or Thawte. (See step 10 - no user will
> import and trust a self-signed applet from an unkown
> developer).
>
> The applet needs to run in the plugin, as only the
> plugin is platform- and browser-independent. And
> without this indepence, it makes no sense to use
> java...
>
> 1. Create your code for the applet as usual.
> It is not necessary to set any permissions or use
> security managers in
> the code.
>
> 2. Install JDK 1.3
> Path for use of the following commands: [jdk 1.3
> path]\bin\
> (commands are keytool, jar, jarsigner)
> Password for the keystore is *any* password. Only Sun
> knows why...
> perhaps ;-)
>
> 3. Generate key: keytool -genkey -keyalg rsa -alias
> tstkey
> Enter keystore password: *******
> What is your first and last name?
> [Unknown]: Your Name
> What is the name of your organizational unit?
> [Unknown]: YourUnit
> What is the name of your organization?
> [Unknown]: YourOrg
> What is the name of your City or Locality?
> [Unknown]: YourCity
> What is the name of your State or Province?
> [Unknown]: YS
> What is the two-letter country code for this unit?
> [Unknown]: US
> Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity,
> ST=YS, C=US
> correct?
> [no]: yes
>
> (wait...)
>
> Enter key password for tstkey
> (RETURN if same as keystore password):
>
> (press [enter])
>
> 4. Export key: keytool -export -alias tstkey -file
> tstcert.crt
>
> Enter keystore password: *******
> Certificate stored in file tstcert.crt
>
> 5. Create JAR: jar cvf tst.jar tst.class
> Add all classes used in your project by typing the
> classnames in the
> same line.
>
> added manifest
> adding: tst.class(in = 849) (out= 536)(deflated 36%)
>
> 6. Verify JAR: jar tvf tst.jar
>
> Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
> 68 Thu Jul 27 12:58:28 GMT+02:00 2000
> META-INF/MANIFEST.MF
> 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
>
> 7. Sign JAR: jarsigner tst.jar tstkey
> Enter Passphrase for keystore: *******
>
> 8. Verifiy Signing: jarsigner -verify -verbose -certs
> tst.jar
>
> 130 Thu Jul 27 13:04:12 GMT+02:00 2000
> META-INF/MANIFEST.MF
> 183 Thu Jul 27 13:04:12 GMT+02:00 2000
> META-INF/TSTKEY.SF
> 920 Thu Jul 27 13:04:12 GMT+02:00 2000
> META-INF/TSTKEY.RSA
> Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
> smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
>
> X.509, CN=Your Name, OU=YourUnit, O=YourOrg,
> L=YourCity, ST=YS, C=US
> (tstkey)
>
> s = signature was verified
> m = entry is listed in manifest
> k = at least one certificate was found in keystore
> i = at least one certificate was found in identity
> scope
>
> jar verified.
>
> 9. Create HTML-File for use of the Applet by the Sun
> Plugin 1.3
> (recommended to use HTML Converter Version 1.3)
>
> 10. (Omitted See Below)
>
> --end irene67's original message --
>
> To make the plug-in work for any browser you have two
> options with the JDK 1.3 plugin.
>
> 1) Is to export a cert request using the key tool and
> send it to a CA verification source like verisign.
> When the reponse comes back, import it into the
> keystore overwriting the original cert for the
> generated key.
>
> To export request:
> keytool -certreg -alias tstkey -file tstcert.req
>
> To import response:
> keytool -import -trustcacerts -alias tstkey -file
> careply.crt
>
> An applet signed with a cert that has been verified
> by a CA source will automatically be recognized by
> the plugin.
>
>
> 2) For development or otherwise, you may want to just
> use your self-signed certificate.
> In that case, the JDK 1.3 plugin will recognize all
> certs that have a root cert located in the JDK 1.3
> cacerts keystore.
> This means you can import your test certificate into
> this keystore and have the plugin recognize your jars
> when you sign them.
>
> To import self-signed certificate into the cacerts
> keystore, change directory to where the JDK plugin
> key store is located.
> For JDK 1.3.0_02: C:\Program
> Files\JavaSoft\JRE\1.3.0_02\lib\security
> For JDK 1.3.1: C:\Program
> Files\JavaSoft\JRE\1.3.1\lib\security
>
> Import your self-signed cert into the cacerts
> keystore:
> keytool -import -keystore cacerts -storepass changeit
> -file tstcert.crt
> (the password is literally 'changeit')
>
>
>
>
> Now, regardless of which method you use, the applet
> should be recognized as coming from a signed jar.
> The user can choose to activate it if he / she
> he chooses. If your applet uses classes from
> multiple jars, for example Apache's Xerce's parser,
> you will need to sign those jars as well to allow
> them to execute in the client's brower. Otherwise,
> only the classes coming from the signed jar will work
> with the java.security.AllPermission setting and all
> other classes from unsigned jars will run in the
> sandbox.
>
>
>
> NOTE: Unless otherwise specified by the -keystore
> command in all keytool and jarsigner operations, the
> keystore file used is named '.keystore' in the user's
> home directory.
>
> The first time any keystore is accessed (including
> the default) it will be created and secured with the
> first password given by the user. There is no way to
> figure out the password if you forget it, but you can
> delete the default file and recreate it if necessary.
> For most operations, using the -keystore command is
> s safer to keep from cluttering or messing up your
> default keystore.
>
cint cinderella
still i have the problem with this :
i hav follow the steps as below:
keytool -genkey -keyalg rsa -alias applkey
keytool -export -alias applkey -file appl.crt
jar cvf appl.jar NervousText.class
jar tvf appl.jar
jarsigner appl.jar applkey
jarsigner -verify -verbose -certs appl.jar
keytool -import -keystore cacerts -storepass changeit -file appl.crt
still it doesnt work:
so when e put all files and certificates,please elaborate it,becoz its urgent.
thanks in advance.
hi..
i've tried your tips..
but at the 6th step, i cannot signed it
when i entered these lines,
jarsigner MyApplet.jar tstkey
Enter Passphrase for keystore: ******
the message is-->
jarsigner: attempt to rename MyApplet.jar to MyApplet.jar.orig failed
help me..
I having the smae problem " attempt to rename .... to .... .orig failed ?(jdk1.3.1_01)
Nobody is ever answering this thread any more :(:(:(No point in posting here, better look for info on other forums or documents, java sun forum seems to have died :(
I had a problem with an Corba connecting applet. But I followed the steps described in your article and signed the applet, and it solved the problem. Tanks a lot for the best tutorial on the subject that I have read.