Signing Software With Netscape Signing Tool 1.1

Table of Contents | Previous | Next | Last

Signing Software with Netscape Signing Tool 1.1


Chapter 2
Using the Netscape Signing Tool

This chapter describes how to use version 1.1 of the Netscape Signing Tool to create digital signatures for files in a directory and to associate the signatures with the files according to the JAR format. Netscape Signing Tool 1.1 also provides an option that automatically creates a JAR file containing the directory; this option was not implemented in pre-1.0 versions. For maximum flexibility, and for compatibility with scripts that used earlier versions of the Netscape Signing Tool, you can still use a ZIP utility to create the JAR file.

For a complete list of the Netscape Signing Tool command-line options, see Chapter 3, "SignTool Syntax and Options."

Sections in this chapter:

Getting Ready to Use the Netscape Signing Tool
Signing a File
Using the Netscape Signing Tool with a ZIP Utility
Tips and Techniques

Getting Ready to Use the Netscape Signing Tool

Before using the Netscape Signing Tool, you must have the signtool executable in your path environment variable. You must also have an object-signing certificate.

Netscape Signing Tool 1.1 includes an option that allows you to generate an object-signing certificate for testing purposes. For information about using this option, see Chapter 4, "Generating Test Object-Signing Certificates."

Although suitable for testing purposes, the object-signing certificate produced by the Netscape Signing Tool is not recommended for signing finished software that will be widely distributed over the Internet or an intranet. When you are ready to sign finished software, you will need to get an object-signing certificate from your company's internal certificate authority, if it has one, or from a third-party certificate authority. Follow the instructions at Object-Signing Tools on Netscape DevEdge to obtain an object-signing certificate from a third party.

The sections that follow describe how to prepare the Netscape Signing Tool for signing files:

Setting Up Your Certificate
Listing Available Certificates

Setting Up Your Certificate

These instructions apply to an object-signing certificate obtained from a third party or an in-house certificate server for use in signing finished code. During development, you may wish to use a special certificate generated by the Netscape Signing Tool for testing purposes. For information about generating and working with a test object-signing certificate, see Chapter 4, "Generating Test Object-Signing Certificates."

If you obtained your object-signing certificate while running Communicator on a system that's different from the system on which you intend to sign files, you need to copy your certificate and private key files to the new system. Communicator's certificate and key databases are portable among all platforms.

On the computer where you ran Communicator to get the object-signing certificate, locate the files key3.db and cert7.db. For example, on a typical Windows NT system, these files are found at C:\Program Files\NETSCAPE\USERS\username\. You must copy these files to the system where you intend to sign pages. (If you use FTP, be sure to transfer in binary mode.)

If you are running the Netscape Signing Tool on a Unix system and you don't already have a ~/.netscape directory, first run Communicator once to create one. If you want to maintain whatever certificates are already in your ~/.netscape directory, put the existing key3.db and cert7.db files in some other directory before replacing them with the versions that include the object-signing certificate you want to use with the Netscape Signing Tool.

If you are using Unix, set up an alias to call signtool, or place it in your path.

If you are using Windows 95 or NT, the signtool executable doesn't know where your certificates are, so either put the key3.db and cert7.db files in the current directory and use "-d." or use -d to point to the directory in which they are located.

WARNING: Keep copies of the key3.db and cert7.db files somewhere separate from the copies you use with the signtool executable. This ensures that you won't lose your certificates if you accidentally damage the files. §

Listing Available Certificates

You use the -L option to list the nicknames for all available certificates and check which ones are signing certificates, as shown in this Unix example:

% signtool -L 
using certificate directory: /u/jsmith/.netscape
S Certificates
- ------------
BBN Certificate Services CA Root 1
IBM World Registry CA
VeriSign Class 1 CA - Individual Subscriber - VeriSign, Inc.
GTE CyberTrust Root CA
Douglas J. Nicolson's Netscape Communications Corporation ID
Uptime Group Plc. Class 4 CA
* Verisign Object Signing Cert
Integrion CA
GTE CyberTrust Secure Server CA
AT&T Directory Services
* test object signing cert
Uptime Group Plc. Class 1 CA
VeriSign Class 1 Primary CA
- ------------
Certificates that can be used to sign objects have *'s to their left.
%
In the above example, two signing certificates are displayed: Verisign Object Signing Cert and test object signing cert.

You use the -l option to get a list of signing certificates only, including the signing CA for each, as shown in this Unix example:

% signtool -l
using certificate directory: /u/jsmith/.netscape
Object signing certificates
---------------------------------------
Verisign Object Signing Cert
    Issued by: VeriSign, Inc. - Verisign, Inc.
    Expires: Tue May 19, 1998
test object signing cert
    Issued by: test object signing cert (Signtool 1.0 Testing Certificate (960187691))
Expires: Sun May 17, 1998
---------------------------------------
For a list including CAs, use "signtool -L"

Signing a File

To sign a file using the Netscape Signing Tool, follow these steps:

1.   Create an empty directory.

% mkdir signdir
2.   Put some file into it.

% echo boo > signdir/test.f
3.    Specify the name of your object-signing certificate and sign the directory.

If you are using Unix, this example assumes you have put your .db files in the
~/.netscape directory, as explained in
Setting Up Your Certificate.
% signtool -k MySignCert -Z testjar.jar signdir

using key "MySignCert"
using certificate directory: /u/jsmith/.netscape
Generating signdir/META-INF/manifest.mf file..
--> test.f
adding signdir/test.f to testjar.jar
Generating signtool.sf file..
Enter Password or Pin for "Communicator Certificate DB":
4.   At the prompt, type the password to your private-key database.

If it accepts the password, signtool responds as follows:
adding signdir/META-INF/manifest.mf to testjar.jar
adding signdir/META-INF/signtool.sf to testjar.jar
adding signdir/META-INF/signtool.rsa to testjar.jar
tree "signdir" signed successfully
5.   Test the archive you just created.

% signtool -v testjar.jar

using certificate directory: /u/jsmith/.netscape
archive "testjar.jar" has passed crypto verification.
           status   path
     ------------ -------------------
         verified test.f
You can also use the Netscape Signing Tool from within a script to automate some aspects of signing. For example, here's a Windows script that starts with an unsigned JAR file, unpackages it, signs it, and then repackages it:

rem Expand the jar file into a new directory
unzip -qq myjar.jar -d signjar
del myjar.jar
rem Sign everything in the new directory and recompress
signtool -k MySignCert -Z myjar.jar signdir

Using the Netscape Signing Tool with a ZIP Utility

To use the Netscape Signing Tool with a ZIP utility, you must have the utility in your path environment variable. You should use the zip.exe utility rather than pkzip.exe, which cannot handle long filenames.

You can use a ZIP utility instead of the -Z option to package a signed archive into a JAR file after you have signed it:

% cd signdir 
% zip -r ../myjar.jar *
adding: META-INF/ (stored 0%)
adding: META-INF/manifest.mf (deflated 15%)
adding: META-INF/signtool.sf (deflated 28%)
adding: META-INF/signtool.rsa (stored 0%)
adding: text.txt (stored 0%)
%

Tips and Techniques


Table of Contents | Previous | Next | Last

Last Updated: 06/19/98 13:23:47

Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use