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>
30 <arg>[-b basename]</arg>
31 <arg>[-c Compression Level] </arg>
32 <arg>[-d cert-dir] </arg>
33 <arg>[-e extension] </arg>
34 <arg>[-f filename] </arg>
35 <arg>[-i installer script] </arg>
40 <arg>[-G nickname]</arg>
42 <arg>[-j directory] </arg>
44 <arg>[--keysize | -s size]</arg>
48 <arg>[-m metafile] </arg>
49 <arg>[--norecurse] </arg>
52 <arg>[--outfile] </arg>
53 <arg>[-p password] </arg>
54 <arg>[-t|--token tokenname] </arg>
58 <arg>[--verbose value] </arg>
59 <arg>[--leavearc] </arg>
60 <arg>[-Z jarfile] </arg>
61 <arg>directory-tree</arg>
63 <!-- this isn't the ideal formatting, since docbook can handle reqiored/optional formatting automatically, but let's make it explicit -->
69 <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>
73 <refsection id="description">
74 <title>Description</title>
76 <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>
77 <para>* Confirm the identity of the individual, company, or other entity whose digital signature is associated with the files</para>
78 <para>* Check whether the files have been tampered with since being signed</para>
79 <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>
80 <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>
81 <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>
82 <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>
83 <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>
84 <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>
85 <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>
86 <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>
87 <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>
90 <refsection id="options">
91 <title>Options</title>
93 <!-- for the moment, I can't find a way for italics and bold tags to work in varlist entries -->
96 <term>-b basename</term>
97 <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>
102 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.
104 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.
108 <term>-d certdir</term>
110 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).
112 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.
116 <term>-e extension</term>
118 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.
122 <term>-f commandfile</term>
124 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".
128 <term>-G nickname</term>
130 Generates a new private-public key pair and corresponding object-signing certificate with the given nickname.
132 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.
134 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.
136 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.
140 <term>-i scriptname</term>
142 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.
149 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.
151 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.
153 If the -c# option is not used with the -J option, the default compression value is 6.
155 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.
160 <term>-j directory</term>
162 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.
166 <term>-k key ... directory</term>
168 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
170 signtool -k MyCert -d . signdir
172 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.
174 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.
180 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.
182 The -l option is available in Netscape Signing Tool 1.0 and later versions only.
188 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.
192 <term>--leavearc</term>
194 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.
198 <term>-m metafile</term>
200 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.
202 The metadata file contains one entry per line, each with three fields:
204 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)
205 field #2: the name of the data you are specifying; for example: Install-Script
206 field #3: data corresponding to the name in field #2
208 For example, the -i option uses the equivalent of this line:
210 + Install-Script: script.js
213 This example associates a MIME type with a file:
215 movie.qt MIME-Type: video/quicktime
217 For information about the way installer script information appears in the manifest file for a JAR archive, see The JAR Format on Netscape DevEdge.
223 Lists the PKCS #11 modules available to signtool, including smart cards.
225 The -M option is available in Netscape Signing Tool 1.0 and later versions only.
227 For information on using Netscape Signing Tool with smart cards, see "Using Netscape Signing Tool with Smart Cards".
229 For information on using the -M option to verify FIPS-140-1 validated mode, see "Netscape Signing Tool and FIPS-140-1".
233 <term>--norecurse</term>
235 Blocks recursion into subdirectories when signing a directory's contents or when parsing HTML.
241 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.
245 <term>--outfile outputfile</term>
247 Specifies a file to receive redirected output from Netscape Signing Tool.
251 <term>-p password</term>
253 Specifies a password for the private-key database. Note that the password entered on the command line is displayed as plain text.
257 <term>-s keysize</term>
259 Specifies the size of the key for generated certificate. Use the -M option to find out what tokens are available.
261 The -s option can be used with the -G option only.
265 <term>-t token</term>
267 Specifies which available token should generate the key and receive the certificate. Use the -M option to find out what tokens are available.
269 The -t option can be used with the -G option only.
273 <term>-v archive</term>
275 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.
279 <term>--verbosity value</term>
281 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.
285 <term>-w archive</term>
287 Displays the names of signers of any files in the archive.
291 <term>-x directory</term>
293 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.
299 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.
303 <term>-Z jarfile</term>
305 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.
307 The -Z option cannot be used at the same time as the -J option.
309 If the -c# option is not used with the -Z option, the default compression value is 6.</para></listitem>
314 <refsection id="command-file">
315 <title>The Command File Format</title>
316 <para>Entries in a Netscape Signing Tool command file have this general format:
319 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>
320 <!-- i'm working on a decent way to do embedded subsections; for now, just use a bold tag to show a new section -->
321 <para><command>Subsection</command></para>
324 <term>basename</term>
325 <listitem><para>Same as -b option.</para></listitem>
328 <term>compression</term>
340 <term>extension</term>
346 <term>generate</term>
352 <term>installscript</term>
358 <term>javascriptdir</term>
370 <term>certname</term>
372 Nickname of certificate, as with -k and -l -k options.
378 The directory to be signed, as with -k option.
384 Same as -l option. Value is ignored, but = sign must be present.
390 Same as -L option. Value is ignored, but = sign must be present.
394 <term>metafile</term>
402 Same as -M option. Value is ignored, but = sign must be present.
406 <term>optimize</term>
408 Same as -o option. Value is ignored, but = sign must be present.
412 <term>password</term>
450 Same as -z option. value is ignored, but = sign must be present.
462 Name of a file to which output and error messages will be redirected. This option has no command-line equivalent.
463 </para></listitem></varlistentry></variablelist>
466 <refsection id="examples">
467 <title>Extended Examples</title>
468 <para>The following example will do this and that
470 <para><command>Listing Available Signing Certificates</command></para>
471 <para>You use the -L option to list the nicknames for all available certificates and check which ones are signing certificates.</para>
472 <programlisting >signtool -L
474 using certificate directory: /u/jsmith/.netscape
477 BBN Certificate Services CA Root 1
478 IBM World Registry CA
479 VeriSign Class 1 CA - Individual Subscriber - VeriSign, Inc.
480 GTE CyberTrust Root CA
481 Uptime Group Plc. Class 4 CA
482 * Verisign Object Signing Cert
484 GTE CyberTrust Secure Server CA
485 AT&T Directory Services
486 * test object signing cert
487 Uptime Group Plc. Class 1 CA
488 VeriSign Class 1 Primary CA
491 Certificates that can be used to sign objects have *'s to their left. </programlisting>
492 <para>Two signing certificates are displayed: Verisign Object Signing Cert and test object signing cert.</para>
493 <para>You use the -l option to get a list of signing certificates only, including the signing CA for each.</para>
494 <programlisting >signtool -l
496 using certificate directory: /u/jsmith/.netscape
497 Object signing certificates
498 ---------------------------------------
500 Verisign Object Signing Cert
501 Issued by: VeriSign, Inc. - Verisign, Inc.
502 Expires: Tue May 19, 1998
503 test object signing cert
504 Issued by: test object signing cert (Signtool 1.0 Testing
505 Certificate (960187691))
506 Expires: Sun May 17, 1998
507 ---------------------------------------</programlisting>
508 <para>For a list including CAs, use the <option>-L</option> option.</para>
510 <para><command>Signing a File</command></para>
511 <para>1. Create an empty directory.</para>
512 <programlisting >mkdir signdir</programlisting>
514 <para>2. Put some file into it.</para>
515 <programlisting >echo boo > signdir/test.f</programlisting>
517 <para>3. Specify the name of your object-signing certificate and sign the directory.</para>
518 <programlisting >signtool -k MySignCert -Z testjar.jar signdir
520 using key "MySignCert"
521 using certificate directory: /u/jsmith/.netscape
522 Generating signdir/META-INF/manifest.mf file..
524 adding signdir/test.f to testjar.jar
525 Generating signtool.sf file..
526 Enter Password or Pin for "Communicator Certificate DB":
528 adding signdir/META-INF/manifest.mf to testjar.jar
529 adding signdir/META-INF/signtool.sf to testjar.jar
530 adding signdir/META-INF/signtool.rsa to testjar.jar
532 tree "signdir" signed successfully</programlisting>
533 <para>4. Test the archive you just created.</para>
534 <programlisting >signtool -v testjar.jar
536 using certificate directory: /u/jsmith/.netscape
537 archive "testjar.jar" has passed crypto verification.
539 ------------ -------------------
540 verified test.f</programlisting>
542 <para><command>Using Netscape Signing Tool with a ZIP Utility</command></para>
543 <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>
544 <programlisting >cd signdir
546 zip -r ../myjar.jar *
547 adding: META-INF/ (stored 0%)
548 adding: META-INF/manifest.mf (deflated 15%)
549 adding: META-INF/signtool.sf (deflated 28%)
550 adding: META-INF/signtool.rsa (stored 0%)
551 adding: text.txt (stored 0%)</programlisting>
553 <para><command>Generating the Keys and Certificate</command></para>
554 <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>
555 <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>
556 <programlisting >signtool -G MyTestCert
558 using certificate directory: /u/someuser/.netscape
559 Enter certificate information. All fields are optional. Acceptable
560 characters are numbers, letters, spaces, and apostrophes.
561 certificate common name: Test Object Signing Certificate
562 organization: Netscape Communications Corp.
563 organization unit: Server Products Division
564 state or province: California
565 country (must be exactly 2 characters): US
567 email address: someuser@netscape.com
568 Enter Password or Pin for "Communicator Certificate DB": [Password will not echo]
569 generated public/private key pair
570 certificate request generated
571 certificate has been signed
572 certificate "MyTestCert" added to database
573 Exported certificate to x509.raw and x509.cacert.</programlisting>
574 <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>
575 <programlisting >signtool -G MyTestCert inputfile</programlisting>
576 <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>
578 <para><command>Using the -M Option to List Smart Cards</command></para>
579 <para>You can use the -M option to list the PKCS #11 modules, including smart cards, that are available to signtool:</para>
580 <programlisting >signtool -d "c:\netscape\users\jsmith" -M
582 using certificate directory: c:\netscape\users\username
583 Listing of PKCS11 modules
584 -----------------------------------------------
585 1. Netscape Internal PKCS #11 Module
586 (this module is internally loaded)
587 slots: 2 slots attached
589 slot: Communicator Internal Cryptographic Services Version 4.0
590 token: Communicator Generic Crypto Svcs
591 slot: Communicator User Private Key and Certificate Services
592 token: Communicator Certificate DB
594 (this is an external module)
596 slots: 1 slots attached
600 ----------------------------------------------- </programlisting>
602 <para><command>Using Netscape Signing Tool and a Smart Card to Sign Files</command></para>
603 <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>
604 <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>
605 <programlisting >signtool -k "MyCard:My Signing Cert" directory</programlisting>
608 <para><command>Verifying FIPS Mode</command></para>
609 <para>Use the -M option to verify that you are using the FIPS-140-1 module.</para>
610 <programlisting >signtool -d "c:\netscape\users\jsmith" -M
612 using certificate directory: c:\netscape\users\jsmith
613 Listing of PKCS11 modules
614 -----------------------------------------------
615 1. Netscape Internal PKCS #11 Module
616 (this module is internally loaded)
617 slots: 2 slots attached
619 slot: Communicator Internal Cryptographic Services Version 4.0
620 token: Communicator Generic Crypto Svcs
621 slot: Communicator User Private Key and Certificate Services
622 token: Communicator Certificate DB
623 -----------------------------------------------</programlisting>
624 <para>This Unix example shows that Netscape Signing Tool is using a FIPS-140-1 module:</para>
625 <programlisting >signtool -d "c:\netscape\users\jsmith" -M
626 using certificate directory: c:\netscape\users\jsmith
627 Enter Password or Pin for "Communicator Certificate DB": [password will not echo]
628 Listing of PKCS11 modules
629 -----------------------------------------------
630 1. Netscape Internal FIPS PKCS #11 Module
631 (this module is internally loaded)
632 slots: 1 slots attached
634 slot: Netscape Internal FIPS-140-1 Cryptographic Services
635 token: Communicator Certificate DB
636 -----------------------------------------------</programlisting>
639 <refsection id="seealso">
640 <title>See Also</title>
641 <para>signver (1)</para>
643 <para>The NSS wiki has information on the new database design and how to configure applications to use it.</para>
647 https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
651 https://wiki.mozilla.org/NSS_Shared_DB
657 <!-- don't change -->
658 <refsection id="resources">
659 <title>Additional Resources</title>
660 <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>
661 <para>Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto</para>
662 <para>IRC: Freenode at #dogtag-pki</para>
665 <!-- fill in your name first; keep the other names for reference -->
666 <refsection id="authors">
667 <title>Authors</title>
668 <para>The NSS tools were written and maintained by developers with Netscape, Red Hat, Sun, Oracle, Mozilla, and Google.</para>
670 Authors: Elio Maldonado <emaldona@redhat.com>, Deon Lackey <dlackey@redhat.com>.
674 <!-- don't change -->
675 <refsection id="license">
676 <title>LICENSE</title>
677 <para>Licensed under the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.