1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4
<!ENTITY date SYSTEM "date.xml">
5
<!ENTITY version SYSTEM "version.xml">
8
<refentry id="signtool">
12
<title>NSS Security Tools</title>
13
<productname>nss-tools</productname>
14
<productnumber>&version;</productnumber>
18
<refentrytitle>signtool</refentrytitle>
19
<manvolnum>1</manvolnum>
23
<refname>signtool</refname>
24
<refpurpose>Digitally sign objects and files.</refpurpose>
29
<command>signtool</command>
38
<arg>[-G nickname]</arg>
39
<arg>[--keysize | -s size]</arg>
40
<arg>[-b basename]</arg>
41
<arg>[-c Compression Level] </arg>
42
<arg>[-d cert-dir] </arg>
43
<arg>[-i installer script] </arg>
44
<arg>[-m metafile] </arg>
46
<arg>[-f filename] </arg>
47
<arg>[-t|--token tokenname] </arg>
48
<arg>[-e extension] </arg>
52
<arg>[--outfile] </arg>
53
<arg>[--verbose value] </arg>
54
<arg>[--norecurse] </arg>
55
<arg>[--leavearc] </arg>
56
<arg>[-j directory] </arg>
57
<arg>[-Z jarfile] </arg>
59
<arg>[-p password] </arg>
60
<arg>directory-tree</arg>
62
<!-- this isn't the ideal formatting, since docbook can handle reqiored/optional formatting automatically, but let's make it explicit -->
68
<para>This documentation is still work in progress. Please contribute to the initial review in <ulink url="https://bugzilla.mozilla.org/show_bug.cgi?id=836477">Mozilla NSS bug 836477</ulink>
72
<refsection id="description">
73
<title>Description</title>
75
<para>The Signing Tool, <command>signtool</command>, creates digital signatures and uses a Java Archive (JAR) file to associate the signatures with files in a directory. Electronic software distribution over any network involves potential security problems. To help address some of these problems, you can associate digital signatures with the files in a JAR archive. Digital signatures allow SSL-enabled clients to perform two important operations:</para>
76
<para>* Confirm the identity of the individual, company, or other entity whose digital signature is associated with the files</para>
77
<para>* Check whether the files have been tampered with since being signed</para>
78
<para>If you have a signing certificate, you can use Netscape Signing Tool to digitally sign files and package them as a JAR file. An object-signing certificate is a special kind of certificate that allows you to associate your digital signature with one or more files.</para>
79
<para>An individual file can potentially be signed with multiple digital signatures. For example, a commercial software developer might sign the files that constitute a software product to prove that the files are indeed from a particular company. A network administrator manager might sign the same files with an additional digital signature based on a company-generated certificate to indicate that the product is approved for use within the company.</para>
80
<para>The significance of a digital signature is comparable to the significance of a handwritten signature. Once you have signed a file, it is difficult to claim later that you didn't sign it. In some situations, a digital signature may be considered as legally binding as a handwritten signature. Therefore, you should take great care to ensure that you can stand behind any file you sign and distribute.</para>
81
<para>For example, if you are a software developer, you should test your code to make sure it is virus-free before signing it. Similarly, if you are a network administrator, you should make sure, before signing any code, that it comes from a reliable source and will run correctly with the software installed on the machines to which you are distributing it.</para>
82
<para>Before you can use Netscape Signing Tool to sign files, you must have an object-signing certificate, which is a special certificate whose associated private key is used to create digital signatures. For testing purposes only, you can create an object-signing certificate with Netscape Signing Tool 1.3. When testing is finished and you are ready to disitribute your software, you should obtain an object-signing certificate from one of two kinds of sources:</para>
83
<para>* An independent certificate authority (CA) that authenticates your identity and charges you a fee. You typically get a certificate from an independent CA if you want to sign software that will be distributed over the Internet.</para>
84
<para>* CA server software running on your corporate intranet or extranet. Netscape Certificate Management System provides a complete management solution for creating, deploying, and managing certificates, including CAs that issue object-signing certificates.</para>
85
<para>You must also have a certificate for the CA that issues your signing certificate before you can sign files. If the certificate authority's certificate isn't already installed in your copy of Communicator, you typically install it by clicking the appropriate link on the certificate authority's web site, for example on the page from which you initiated enrollment for your signing certificate. This is the case for some test certificates, as well as certificates issued by Netscape Certificate Management System: you must download the the CA certificate in addition to obtaining your own signing certificate. CA certificates for several certificate authorities are preinstalled in the Communicator certificate database.</para>
86
<para>When you receive an object-signing certificate for your own use, it is automatically installed in your copy of the Communicator client software. Communicator supports the public-key cryptography standard known as PKCS #12, which governs key portability. You can, for example, move an object-signing certificate and its associated private key from one computer to another on a credit-card-sized device called a smart card.</para>
89
<refsection id="options">
90
<title>Options</title>
92
<!-- for the moment, I can't find a way for italics and bold tags to work in varlist entries -->
95
<term>-b basename</term>
96
<listitem><para>Specifies the base filename for the .rsa and .sf files in the META-INF directory to conform with the JAR format. For example, <emphasis>-b signatures</emphasis> causes the files to be named signatures.rsa and signatures.sf. The default is signtool.</para></listitem>
101
Specifies the compression level for the -J or -Z option. The symbol # represents a number from 0 to 9, where 0 means no compression and 9 means maximum compression. The higher the level of compression, the smaller the output but the longer the operation takes.
103
If the -c# option is not used with either the -J or the -Z option, the default compression value used by both the -J and -Z options is 6.
107
<term>-d certdir</term>
109
Specifies your certificate database directory; that is, the directory in which you placed your key3.db and cert7.db files. To specify the current directory, use "-d." (including the period).
111
The Unix version of signtool assumes ~/.netscape unless told otherwise. The NT version of signtool always requires the use of the -d option to specify where the database files are located.
115
<term>-e extension</term>
117
Tells signtool to sign only files with the given extension; for example, use -e".class" to sign only Java class files. Note that with Netscape Signing Tool version 1.1 and later this option can appear multiple times on one command line, making it possible to specify multiple file types or classes to include.
121
<term>-f commandfile</term>
123
Specifies a text file containing Netscape Signing Tool options and arguments in keyword=value format. All options and arguments can be expressed through this file. For more information about the syntax used with this file, see "Tips and Techniques".
127
<term>-i scriptname</term>
129
Specifies the name of an installer script for SmartUpdate. This script installs files from the JAR archive in the local system after SmartUpdate has validated the digital signature. For more details, see the description of -m that follows. The -i option provides a straightforward way to provide this information if you don't need to specify any metadata other than an installer script.
133
<term>-j directory</term>
135
Specifies a special JavaScript directory. This option causes the specified directory to be signed and tags its entries as inline JavaScript. This special type of entry does not have to appear in the JAR file itself. Instead, it is located in the HTML page containing the inline scripts. When you use signtool -v, these entries are displayed with the string NOT PRESENT.
139
<term>-k key ... directory</term>
141
Specifies the nickname (key) of the certificate you want to sign with and signs the files in the specified directory. The directory to sign is always specified as the last command-line argument. Thus, it is possible to write
143
signtool -k MyCert -d . signdir
145
You may have trouble if the nickname contains a single quotation mark. To avoid problems, escape the quotation mark using the escape conventions for your platform.
147
It's also possible to use the -k option without signing any files or specifying a directory. For example, you can use it with the -l option to get detailed information about a particular signing certificate.
151
<term>-G nickname</term>
153
Generates a new private-public key pair and corresponding object-signing certificate with the given nickname.
155
The newly generated keys and certificate are installed into the key and certificate databases in the directory specified by the -d option. With the NT version of Netscape Signing Tool, you must use the -d option with the -G option. With the Unix version of Netscape Signing Tool, omitting the -d option causes the tool to install the keys and certificate in the Communicator key and certificate databases. If you are installing the keys and certificate in the Communicator databases, you must exit Communicator before using this option; otherwise, you risk corrupting the databases. In all cases, the certificate is also output to a file named x509.cacert, which has the MIME-type application/x-x509-ca-cert.
157
Unlike certificates normally used to sign finished code to be distributed over a network, a test certificate created with -G is not signed by a recognized certificate authority. Instead, it is self-signed. In addition, a single test signing certificate functions as both an object-signing certificate and a CA. When you are using it to sign objects, it behaves like an object-signing certificate. When it is imported into browser software such as Communicator, it behaves like an object-signing CA and cannot be used to sign objects.
159
The -G option is available in Netscape Signing Tool 1.0 and later versions only. By default, it produces only RSA certificates with 1024-byte keys in the internal token. However, you can use the -s option specify the required key size and the -t option to specify the token. For more information about the use of the -G option, see "Generating Test Object-Signing Certificates""Generating Test Object-Signing Certificates" on page 1241.
165
Lists signing certificates, including issuing CAs. If any of your certificates are expired or invalid, the list will so specify. This option can be used with the -k option to list detailed information about a particular signing certificate.
167
The -l option is available in Netscape Signing Tool 1.0 and later versions only.
173
Signs a directory of HTML files containing JavaScript and creates as many archive files as are specified in the HTML tags. Even if signtool creates more than one archive file, you need to supply the key database password only once.
175
The -J option is available only in Netscape Signing Tool 1.0 and later versions. The -J option cannot be used at the same time as the -Z option.
177
If the -c# option is not used with the -J option, the default compression value is 6.
179
Note that versions 1.1 and later of Netscape Signing Tool correctly recognizes the CODEBASE attribute, allows paths to be expressed for the CLASS and SRC attributes instead of filenames only, processes LINK tags and parses HTML correctly, and offers clearer error messages.
185
Lists the certificates in your database. An asterisk appears to the left of the nickname for any certificate that can be used to sign objects with signtool.
189
<term>--leavearc</term>
191
Retains the temporary .arc (archive) directories that the -J option creates. These directories are automatically erased by default. Retaining the temporary directories can be an aid to debugging.
195
<term>-m metafile</term>
197
Specifies the name of a metadata control file. Metadata is signed information attached either to the JAR archive itself or to files within the archive. This metadata can be any ASCII string, but is used mainly for specifying an installer script.
199
The metadata file contains one entry per line, each with three fields:
201
field #1: file specification, or + if you want to specify global metadata (that is, metadata about the JAR archive itself or all entries in the archive)
202
field #2: the name of the data you are specifying; for example: Install-Script
203
field #3: data corresponding to the name in field #2
205
For example, the -i option uses the equivalent of this line:
207
+ Install-Script: script.js
210
This example associates a MIME type with a file:
212
movie.qt MIME-Type: video/quicktime
214
For information about the way installer script information appears in the manifest file for a JAR archive, see The JAR Format on Netscape DevEdge.
220
Lists the PKCS #11 modules available to signtool, including smart cards.
222
The -M option is available in Netscape Signing Tool 1.0 and later versions only.
224
For information on using Netscape Signing Tool with smart cards, see "Using Netscape Signing Tool with Smart Cards".
226
For information on using the -M option to verify FIPS-140-1 validated mode, see "Netscape Signing Tool and FIPS-140-1".
230
<term>--norecurse</term>
232
Blocks recursion into subdirectories when signing a directory's contents or when parsing HTML.
238
Optimizes the archive for size. Use this only if you are signing very large archives containing hundreds of files. This option makes the manifest files (required by the JAR format) considerably smaller, but they contain slightly less information.
242
<term>--outfile outputfile</term>
244
Specifies a file to receive redirected output from Netscape Signing Tool.
248
<term>-p password</term>
250
Specifies a password for the private-key database. Note that the password entered on the command line is displayed as plain text.
254
<term>-s keysize</term>
256
Specifies the size of the key for generated certificate. Use the -M option to find out what tokens are available.
258
The -s option can be used with the -G option only.
262
<term>-t token</term>
264
Specifies which available token should generate the key and receive the certificate. Use the -M option to find out what tokens are available.
266
The -t option can be used with the -G option only.
270
<term>-v archive</term>
272
Displays the contents of an archive and verifies the cryptographic integrity of the digital signatures it contains and the files with which they are associated. This includes checking that the certificate for the issuer of the object-signing certificate is listed in the certificate database, that the CA's digital signature on the object-signing certificate is valid, that the relevant certificates have not expired, and so on.
276
<term>--verbosity value</term>
278
Sets the quantity of information Netscape Signing Tool generates in operation. A value of 0 (zero) is the default and gives full information. A value of -1 suppresses most messages, but not error messages.
282
<term>-w archive</term>
284
Displays the names of signers of any files in the archive.
288
<term>-x directory</term>
290
Excludes the specified directory from signing. Note that with Netscape Signing Tool version 1.1 and later this option can appear multiple times on one command line, making it possible to specify several particular directories to exclude.
296
Tells signtool not to store the signing time in the digital signature. This option is useful if you want the expiration date of the signature checked against the current date and time rather than the time the files were signed.
300
<term>-Z jarfile</term>
302
Creates a JAR file with the specified name. You must specify this option if you want signtool to create the JAR file; it does not do so automatically. If you don't specify -Z, you must use an external ZIP tool to create the JAR file.
304
The -Z option cannot be used at the same time as the -J option.
306
If the -c# option is not used with the -Z option, the default compression value is 6.</para></listitem>
311
<refsection id="command-file">
312
<title>The Command File Format</title>
313
<para>Entries in a Netscape Signing Tool command file have this general format:
316
Everything before the = sign on a single line is a keyword, and everything from the = sign to the end of line is a value. The value may include = signs; only the first = sign on a line is interpreted. Blank lines are ignored, but white space on a line with keywords and values is assumed to be part of the keyword (if it comes before the equal sign) or part of the value (if it comes after the first equal sign). Keywords are case insensitive, values are generally case sensitive. Since the = sign and newline delimit the value, it should not be quoted. </para>
317
<!-- i'm working on a decent way to do embedded subsections; for now, just use a bold tag to show a new section -->
318
<para><command>Subsection</command></para>
321
<term>basename</term>
322
<listitem><para>Same as -b option.</para></listitem>
325
<term>compression</term>
337
<term>extension</term>
343
<term>generate</term>
349
<term>installscript</term>
355
<term>javascriptdir</term>
367
<term>certname</term>
369
Nickname of certificate, as with -k and -l -k options.
375
The directory to be signed, as with -k option.
381
Same as -l option. Value is ignored, but = sign must be present.
387
Same as -L option. Value is ignored, but = sign must be present.
391
<term>metafile</term>
399
Same as -M option. Value is ignored, but = sign must be present.
403
<term>optimize</term>
405
Same as -o option. Value is ignored, but = sign must be present.
409
<term>password</term>
447
Same as -z option. value is ignored, but = sign must be present.
459
Name of a file to which output and error messages will be redirected. This option has no command-line equivalent.
460
</para></listitem></varlistentry></variablelist>
463
<refsection id="examples">
464
<title>Extended Examples</title>
465
<para>The following example will do this and that
467
<para><command>Listing Available Signing Certificates</command></para>
468
<para>You use the -L option to list the nicknames for all available certificates and check which ones are signing certificates.</para>
469
<programlisting >signtool -L
471
using certificate directory: /u/jsmith/.netscape
474
BBN Certificate Services CA Root 1
475
IBM World Registry CA
476
VeriSign Class 1 CA - Individual Subscriber - VeriSign, Inc.
477
GTE CyberTrust Root CA
478
Uptime Group Plc. Class 4 CA
479
* Verisign Object Signing Cert
481
GTE CyberTrust Secure Server CA
482
AT&T Directory Services
483
* test object signing cert
484
Uptime Group Plc. Class 1 CA
485
VeriSign Class 1 Primary CA
488
Certificates that can be used to sign objects have *'s to their left. </programlisting>
489
<para>Two signing certificates are displayed: Verisign Object Signing Cert and test object signing cert.</para>
490
<para>You use the -l option to get a list of signing certificates only, including the signing CA for each.</para>
491
<programlisting >signtool -l
493
using certificate directory: /u/jsmith/.netscape
494
Object signing certificates
495
---------------------------------------
497
Verisign Object Signing Cert
498
Issued by: VeriSign, Inc. - Verisign, Inc.
499
Expires: Tue May 19, 1998
500
test object signing cert
501
Issued by: test object signing cert (Signtool 1.0 Testing
502
Certificate (960187691))
503
Expires: Sun May 17, 1998
504
---------------------------------------</programlisting>
505
<para>For a list including CAs, use the <option>-L</option> option.</para>
507
<para><command>Signing a File</command></para>
508
<para>1. Create an empty directory.</para>
509
<programlisting >mkdir signdir</programlisting>
511
<para>2. Put some file into it.</para>
512
<programlisting >echo boo > signdir/test.f</programlisting>
514
<para>3. Specify the name of your object-signing certificate and sign the directory.</para>
515
<programlisting >signtool -k MySignCert -Z testjar.jar signdir
517
using key "MySignCert"
518
using certificate directory: /u/jsmith/.netscape
519
Generating signdir/META-INF/manifest.mf file..
521
adding signdir/test.f to testjar.jar
522
Generating signtool.sf file..
523
Enter Password or Pin for "Communicator Certificate DB":
525
adding signdir/META-INF/manifest.mf to testjar.jar
526
adding signdir/META-INF/signtool.sf to testjar.jar
527
adding signdir/META-INF/signtool.rsa to testjar.jar
529
tree "signdir" signed successfully</programlisting>
530
<para>4. Test the archive you just created.</para>
531
<programlisting >signtool -v testjar.jar
533
using certificate directory: /u/jsmith/.netscape
534
archive "testjar.jar" has passed crypto verification.
536
------------ -------------------
537
verified test.f</programlisting>
539
<para><command>Using Netscape Signing Tool with a ZIP Utility</command></para>
540
<para>To use 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:</para>
541
<programlisting >cd signdir
543
zip -r ../myjar.jar *
544
adding: META-INF/ (stored 0%)
545
adding: META-INF/manifest.mf (deflated 15%)
546
adding: META-INF/signtool.sf (deflated 28%)
547
adding: META-INF/signtool.rsa (stored 0%)
548
adding: text.txt (stored 0%)</programlisting>
550
<para><command>Generating the Keys and Certificate</command></para>
551
<para>The signtool option -G generates a new public-private key pair and certificate. It takes the nickname of the new certificate as an argument. The newly generated keys and certificate are installed into the key and certificate databases in the directory specified by the -d option. With the NT version of Netscape Signing Tool, you must use the -d option with the -G option. With the Unix version of Netscape Signing Tool, omitting the -d option causes the tool to install the keys and certificate in the Communicator key and certificate databases. In all cases, the certificate is also output to a file named x509.cacert, which has the MIME-type application/x-x509-ca-cert.</para>
552
<para>Certificates contain standard information about the entity they identify, such as the common name and organization name. Netscape Signing Tool prompts you for this information when you run the command with the -G option. However, all of the requested fields are optional for test certificates. If you do not enter a common name, the tool provides a default name. In the following example, the user input is in boldface:</para>
553
<programlisting >signtool -G MyTestCert
555
using certificate directory: /u/someuser/.netscape
556
Enter certificate information. All fields are optional. Acceptable
557
characters are numbers, letters, spaces, and apostrophes.
558
certificate common name: Test Object Signing Certificate
559
organization: Netscape Communications Corp.
560
organization unit: Server Products Division
561
state or province: California
562
country (must be exactly 2 characters): US
564
email address: someuser@netscape.com
565
Enter Password or Pin for "Communicator Certificate DB": [Password will not echo]
566
generated public/private key pair
567
certificate request generated
568
certificate has been signed
569
certificate "MyTestCert" added to database
570
Exported certificate to x509.raw and x509.cacert.</programlisting>
571
<para>The certificate information is read from standard input. Therefore, the information can be read from a file using the redirection operator (<) in some operating systems. To create a file for this purpose, enter each of the seven input fields, in order, on a separate line. Make sure there is a newline character at the end of the last line. Then run signtool with standard input redirected from your file as follows:</para>
572
<programlisting >signtool -G MyTestCert inputfile</programlisting>
573
<para>The prompts show up on the screen, but the responses will be automatically read from the file. The password will still be read from the console unless you use the -p option to give the password on the command line.</para>
575
<para><command>Using the -M Option to List Smart Cards</command></para>
576
<para>You can use the -M option to list the PKCS #11 modules, including smart cards, that are available to signtool:</para>
577
<programlisting >signtool -d "c:\netscape\users\jsmith" -M
579
using certificate directory: c:\netscape\users\username
580
Listing of PKCS11 modules
581
-----------------------------------------------
582
1. Netscape Internal PKCS #11 Module
583
(this module is internally loaded)
584
slots: 2 slots attached
586
slot: Communicator Internal Cryptographic Services Version 4.0
587
token: Communicator Generic Crypto Svcs
588
slot: Communicator User Private Key and Certificate Services
589
token: Communicator Certificate DB
591
(this is an external module)
593
slots: 1 slots attached
597
----------------------------------------------- </programlisting>
599
<para><command>Using Netscape Signing Tool and a Smart Card to Sign Files</command></para>
600
<para>The signtool command normally takes an argument of the -k option to specify a signing certificate. To sign with a smart card, you supply only the fully qualified name of the certificate.</para>
601
<para>To see fully qualified certificate names when you run Communicator, click the Security button in Navigator, then click Yours under Certificates in the left frame. Fully qualified names are of the format smart card:certificate, for example "MyCard:My Signing Cert". You use this name with the -k argument as follows:</para>
602
<programlisting >signtool -k "MyCard:My Signing Cert" directory</programlisting>
605
<para><command>Verifying FIPS Mode</command></para>
606
<para>Use the -M option to verify that you are using the FIPS-140-1 module.</para>
607
<programlisting >signtool -d "c:\netscape\users\jsmith" -M
609
using certificate directory: c:\netscape\users\jsmith
610
Listing of PKCS11 modules
611
-----------------------------------------------
612
1. Netscape Internal PKCS #11 Module
613
(this module is internally loaded)
614
slots: 2 slots attached
616
slot: Communicator Internal Cryptographic Services Version 4.0
617
token: Communicator Generic Crypto Svcs
618
slot: Communicator User Private Key and Certificate Services
619
token: Communicator Certificate DB
620
-----------------------------------------------</programlisting>
621
<para>This Unix example shows that Netscape Signing Tool is using a FIPS-140-1 module:</para>
622
<programlisting >signtool -d "c:\netscape\users\jsmith" -M
623
using certificate directory: c:\netscape\users\jsmith
624
Enter Password or Pin for "Communicator Certificate DB": [password will not echo]
625
Listing of PKCS11 modules
626
-----------------------------------------------
627
1. Netscape Internal FIPS PKCS #11 Module
628
(this module is internally loaded)
629
slots: 1 slots attached
631
slot: Netscape Internal FIPS-140-1 Cryptographic Services
632
token: Communicator Certificate DB
633
-----------------------------------------------</programlisting>
636
<refsection id="seealso">
637
<title>See Also</title>
638
<para>signver (1)</para>
640
<para>The NSS wiki has information on the new database design and how to configure applications to use it.</para>
644
https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
648
https://wiki.mozilla.org/NSS_Shared_DB
654
<!-- don't change -->
655
<refsection id="resources">
656
<title>Additional Resources</title>
657
<para>For information about NSS and other tools related to NSS (like JSS), check out the NSS project wiki at <ulink url="http://www.mozilla.org/projects/security/pki/nss/">http://www.mozilla.org/projects/security/pki/nss/</ulink>. The NSS site relates directly to NSS code changes and releases.</para>
658
<para>Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto</para>
659
<para>IRC: Freenode at #dogtag-pki</para>
662
<!-- fill in your name first; keep the other names for reference -->
663
<refsection id="authors">
664
<title>Authors</title>
665
<para>The NSS tools were written and maintained by developers with Netscape, Red Hat, and Sun.</para>
667
Authors: Elio Maldonado <emaldona@redhat.com>, Deon Lackey <dlackey@redhat.com>.
671
<!-- don't change -->
672
<refsection id="license">
673
<title>LICENSE</title>
674
<para>Licensed under the Mozilla Public License, version 1.1,
675
and/or the GNU General Public License, version 2 or later,
676
and/or the GNU Lesser General Public License, version 2.1 or later.