«^»
5.3. Adding a Digital Signature to a Java Archive

You now need to digitally sign the jar file. This is complicated. First, you need to use JDK 1.1.x's javakey command to generate an identity. For example, suppose you want to use the identity Barry. You can do this by typing the Unix/MS-DOS command:

javakey -cs "Barry" true
On a Unix system, this command creates a file called identitydb.obj in your home directory, whereas on Microsoft's Windows 95/NT it will create the file in the top directory of your JDK's directory tree. Whenever you use the javakey to make a change, you can check what has happened using:
javakey -ld

You can now create a pair of keys (a private key and a public key) to be used by this identity. This can be done using the command:

javakey -gk "Barry" DSA 1024

You now use a text editor to create a certificate directive file. Suppose the file Barry.cdirective contains the lines:

issuer.name=Barry
issuer.cert=1
subject.name=Barry
subject.real.name=Barry Cornelius
subject.org.unit=IT Service
subject.org=University of Durham
subject.country=UK
start.date=1 Nov 1997
end.date=30 Nov 1997
serial.number=1
out.file=Barry.x509
You can then issue the command:
javakey -gc Barry.cdirective
This alters the file identitydb.obj and also creates the file Barry.x509.

You are now (at long last) in a position to sign your jar file. First, you need to use a text editor to create a signature directive file. Suppose the file Barry.sdirective contains the lines:

signer=Barry
cert=1
chain=0
signature.file=Barry
Then type the command:
javakey -gs Barry.sdirective AgesLet.jar
This creates a signed version of your jar file in a file called AgesLet.jar.sig.