Imported Upstream version 3.17
[platform/upstream/nss.git] / doc / certutil.xml
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">
6 ]>
7
8 <refentry id="certutil">
9
10   <refentryinfo>
11     <date>&date;</date>
12     <title>NSS Security Tools</title>
13     <productname>nss-tools</productname>
14     <productnumber>&version;</productnumber>
15   </refentryinfo>
16
17   <refmeta>
18     <refentrytitle>CERTUTIL</refentrytitle>
19     <manvolnum>1</manvolnum>
20   </refmeta>
21
22   <refnamediv>
23     <refname>certutil</refname>
24     <refpurpose>Manage keys and certificate in both NSS databases and other NSS tokens</refpurpose>
25   </refnamediv>
26
27   <refsynopsisdiv>
28     <cmdsynopsis>
29       <command>certutil</command>
30       <arg><replaceable>options</replaceable></arg>
31       <arg>[<replaceable>arguments</replaceable>]</arg>
32     </cmdsynopsis>
33   </refsynopsisdiv>
34
35   <refsection>
36     <title>STATUS</title>
37     <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>
38     </para>
39   </refsection>
40
41 <refsection id="description">
42     <title>Description</title>
43
44     <para>The Certificate Database Tool, <command>certutil</command>, is a command-line utility that can create and modify certificate and key databases. It can specifically list, generate, modify, or delete certificates, create or change the password, generate new public and private key pairs, display the contents of the key database, or delete key pairs within the key database.</para>
45     <para>Certificate issuance, part of the key and certificate management process, requires that keys and certificates be created in the key database. This document discusses certificate and key database management. For information on the security module database management, see the <command>modutil</command> manpage.</para>
46
47   </refsection>
48   
49   <refsection id="options">
50     <title>Command Options and Arguments</title>
51         <para>Running <command>certutil</command> always requires one and only one command option to specify the type of certificate operation. Each command option may take zero or more arguments. The command option <option>-H</option> will list all the command options and their relevant arguments.</para>
52         <para><command>Command Options</command></para> 
53     <variablelist>
54
55       <varlistentry>
56         <term>-A </term>
57         <listitem><para>Add an existing certificate to a certificate database. The certificate database should already exist; if one is not present, this command option will initialize one by default.</para></listitem>
58       </varlistentry>
59
60       <varlistentry>
61         <term>-B</term>
62         <listitem><para>Run a series of commands from the specified batch file. This requires the <option>-i</option> argument.</para></listitem>
63       </varlistentry>
64     
65       <varlistentry>
66         <term>-C </term>
67         <listitem><para>Create a new binary certificate file from a binary certificate request file. Use the <option>-i</option> argument to specify the certificate request file. If this argument is not used, <command>certutil</command> prompts for a filename. </para></listitem>
68       </varlistentry>
69
70       <varlistentry>
71         <term>-D </term>
72         <listitem><para>Delete a certificate from the certificate database.</para></listitem>
73       </varlistentry>
74
75       <varlistentry>
76         <term>-E </term>
77         <listitem><para>Add an email certificate to the certificate database.</para></listitem>
78       </varlistentry>
79
80       <varlistentry>
81         <term>-F</term>
82         <listitem><para>Delete a private key from a key database. Specify the key to delete with the -n argument. Specify the database from which to delete the key with the 
83 <option>-d</option> argument. Use the <option>-k</option> argument to specify explicitly whether to delete a DSA, RSA, or ECC key. If you don't use the <option>-k</option> argument, the option looks for an RSA key matching the specified nickname. 
84 </para>
85 <para>
86 When you delete keys, be sure to also remove any certificates associated with those keys from the certificate database, by using -D. Some smart cards do not let you remove a public key you have generated. In such a case, only the private key is deleted from the key pair. You can display the public key with the command certutil -K -h tokenname. </para></listitem>
87       </varlistentry>
88
89       <varlistentry>
90         <term>-G </term>
91         <listitem><para>Generate a new public and private key pair within a key database. The key database should already exist; if one is not present, this command option will initialize one by default. Some smart cards can store only one key pair. If you create a new key pair for such a card, the previous pair is overwritten.</para></listitem>
92       </varlistentry>
93
94       <varlistentry>
95         <term>-H </term>
96         <listitem><para>Display a list of the command options and arguments.</para></listitem>
97       </varlistentry>
98
99       <varlistentry>
100         <term>-K </term>
101         <listitem><para>List the key ID of keys in the key database. A key ID is the modulus of the RSA key or the publicValue of the DSA key. IDs are displayed in hexadecimal ("0x" is not shown).</para></listitem>
102       </varlistentry>
103
104       <varlistentry>
105         <term>-L </term>
106         <listitem><para>List all the certificates, or display information about a named certificate, in a certificate database.
107 Use the -h tokenname argument to specify the certificate database on a particular hardware or software token.</para></listitem>
108       </varlistentry>
109
110       <varlistentry>
111         <term>-M </term>
112         <listitem><para>Modify a certificate's trust attributes using the values of the -t argument.</para></listitem>
113       </varlistentry>
114
115       <varlistentry>
116         <term>-N</term>
117         <listitem><para>Create new certificate and key databases.</para></listitem>
118       </varlistentry>
119
120       <varlistentry>
121         <term>-O </term>
122         <listitem><para>Print the certificate chain.</para></listitem>
123       </varlistentry>
124
125       <varlistentry>
126         <term>-R</term>
127         <listitem><para>Create a certificate request file that can be submitted to a Certificate Authority (CA) for processing into a finished certificate. Output defaults to standard out unless you use -o output-file argument.
128
129 Use the -a argument to specify ASCII output.</para></listitem>
130       </varlistentry>
131
132       <varlistentry>
133         <term>-S </term>
134         <listitem><para>Create an individual certificate and add it to a certificate database.</para></listitem>
135       </varlistentry>
136
137       <varlistentry>
138         <term>-T </term>
139         <listitem><para>Reset the key database or token.</para></listitem>
140       </varlistentry>
141
142       <varlistentry>
143         <term>-U </term>
144         <listitem><para>List all available modules or print a single named module.</para></listitem>
145       </varlistentry>
146
147       <varlistentry>
148         <term>-V </term>
149         <listitem><para>Check the validity of a certificate and its attributes.</para></listitem>
150       </varlistentry>
151
152       <varlistentry>
153         <term>-W </term>
154         <listitem><para>Change the password to a key database.</para></listitem>
155       </varlistentry>
156
157       <varlistentry>
158         <term>--merge</term>
159         <listitem><para>Merge two databases into one.</para></listitem>
160       </varlistentry>
161
162       <varlistentry>
163         <term>--upgrade-merge</term>
164         <listitem><para>Upgrade an old database and merge it into a new database. This is used to migrate legacy NSS databases (<filename>cert8.db</filename> and <filename>key3.db</filename>) into the newer SQLite databases (<filename>cert9.db</filename> and <filename>key4.db</filename>).</para></listitem>
165       </varlistentry>
166         </variablelist>
167
168         <para><command>Arguments</command></para>
169         <para>Arguments modify a command option and are usually lower case, numbers, or symbols.</para>
170         <variablelist>
171       <varlistentry>
172         <term>-a</term>
173         <listitem><para>Use ASCII format or allow the use of ASCII format for input or output. This formatting follows RFC 1113. 
174 For certificate requests, ASCII output defaults to standard output unless redirected.</para></listitem>
175       </varlistentry>
176
177       <varlistentry>
178         <term>-b validity-time</term>
179         <listitem><para>Specify a time at which a certificate is required to be valid. Use when checking certificate validity with the <option>-V</option> option. The format of the <emphasis>validity-time</emphasis> argument is <emphasis>YYMMDDHHMMSS[+HHMM|-HHMM|Z]</emphasis>, which allows offsets to be set relative to the validity end time. Specifying seconds (<emphasis>SS</emphasis>) is optional. When specifying an explicit time, use a Z at the end of the term, <emphasis>YYMMDDHHMMSSZ</emphasis>, to close it. When specifying an offset time, use <emphasis>YYMMDDHHMMSS+HHMM</emphasis> or <emphasis>YYMMDDHHMMSS-HHMM</emphasis> for adding or subtracting time, respectively.
180 </para>
181 <para>
182 If this option is not used, the validity check defaults to the current system time.</para></listitem>
183       </varlistentry>
184
185       <varlistentry>
186         <term>-c issuer</term>
187         <listitem><para>Identify the certificate of the CA from which a new certificate will derive its authenticity. 
188  Use the exact nickname or alias of the CA certificate, or use the CA's email address. Bracket the issuer string 
189  with quotation marks if it contains spaces. </para></listitem>
190       </varlistentry>
191
192       <varlistentry>
193         <term>-d [prefix]directory</term>
194         <listitem>
195           <para>Specify the database directory containing the certificate and key database files.</para>
196           <para><command>certutil</command> supports two types of databases: the legacy security databases (<filename>cert8.db</filename>, <filename>key3.db</filename>, and <filename>secmod.db</filename>) and new SQLite databases (<filename>cert9.db</filename>, <filename>key4.db</filename>, and <filename>pkcs11.txt</filename>). </para>
197           <para>NSS recognizes the following prefixes:</para>
198           <itemizedlist>
199             <listitem><para><command>sql:</command> requests the newer database</para></listitem>
200             <listitem><para><command>dbm:</command> requests the legacy database</para></listitem>
201           </itemizedlist>
202           <para>If no prefix is specified the default type is retrieved from NSS_DEFAULT_DB_TYPE. If NSS_DEFAULT_DB_TYPE is not set then <command>dbm:</command> is the default.</para>
203         </listitem>
204       </varlistentry>
205
206       <varlistentry>
207         <term>--dump-ext-val OID </term>
208         <listitem><para>For single cert, print binary DER encoding of extension OID.</para></listitem>
209       </varlistentry>
210
211       <varlistentry>
212         <term>-e </term>
213         <listitem><para>Check a certificate's signature during the process of validating a certificate.</para></listitem>
214       </varlistentry>
215
216       <varlistentry>
217         <term>--email email-address</term>
218         <listitem><para>Specify the email address of a certificate to list. Used with the -L command option.</para></listitem>
219       </varlistentry>
220
221       <varlistentry>
222         <term>--extGeneric OID:critical-flag:filename[,OID:critical-flag:filename]... </term>
223         <listitem>
224           <para>
225 Add one or multiple extensions that certutil cannot encode yet, by loading their encodings from external files.
226            </para>
227         <itemizedlist>
228         <listitem>
229 <para>OID (example): 1.2.3.4</para>
230         </listitem>
231         <listitem>
232 <para>critical-flag: critical or not-critical</para>
233         </listitem>
234         <listitem>
235 <para>filename: full path to a file containing an encoded extension</para>
236         </listitem>
237         </itemizedlist>
238         </listitem>
239       </varlistentry>
240
241       <varlistentry>
242         <term>-f password-file</term>
243         <listitem><para>Specify a file that will automatically supply the password to include in a certificate 
244  or to access a certificate database. This is a plain-text file containing one password. Be sure to prevent 
245  unauthorized access to this file.</para></listitem>
246       </varlistentry>
247
248       <varlistentry>
249         <term>-g keysize</term>
250         <listitem><para>Set a key size to use when generating new public and private key pairs. The minimum is 512 bits and the maximum is 16384 bits. The default is 1024 bits. Any size between the minimum and maximum is allowed.</para></listitem>
251       </varlistentry>
252
253
254       <varlistentry>
255         <term>-h tokenname</term>
256         <listitem><para>Specify the name of a token to use or act on. If not specified the default token is the internal database slot.</para></listitem>
257       </varlistentry>
258
259      <varlistentry>
260         <term>-i input_file</term>
261         <listitem><para>Pass an input file to the command. Depending on the command option, an input file can be a specific certificate, a certificate request file, or a batch file of commands.</para></listitem>
262       </varlistentry>
263
264       <varlistentry>
265         <term>-k key-type-or-id</term>
266         <listitem>
267           <para>Specify the type or specific ID of a key.</para>
268           <para>
269            The valid key type options are rsa, dsa, ec, or all. The default 
270            value is rsa. Specifying the type of key can avoid mistakes caused by
271            duplicate nicknames. Giving a key type generates a new key pair; 
272            giving the ID of an existing key reuses that key pair (which is 
273            required to renew certificates).
274           </para>
275         </listitem>
276       </varlistentry>
277
278       <varlistentry>
279         <term>-l </term>
280         <listitem><para>Display detailed information when validating a certificate with the -V option.</para></listitem>
281       </varlistentry>
282
283       <varlistentry>
284         <term>-m serial-number</term>
285         <listitem><para>Assign a unique serial number to a certificate being created. This operation should be performed by a CA. If no serial number is provided a default serial number is made from the current time. Serial numbers are limited to integers </para></listitem>
286       </varlistentry>
287
288       <varlistentry>
289         <term>-n nickname</term>
290         <listitem><para>Specify the nickname of a certificate or key to list, create, add to a database, modify, or validate. Bracket the nickname string with quotation marks if it contains spaces.</para></listitem>
291       </varlistentry>
292
293       <varlistentry>
294         <term>-o output-file</term>
295         <listitem><para>Specify the output file name for new certificates or binary certificate requests. Bracket the output-file string with quotation marks if it contains spaces. If this argument is not used the output destination defaults to standard output.</para></listitem>
296       </varlistentry>
297
298       <varlistentry>
299         <term>-P dbPrefix</term>
300         <listitem><para>Specify the prefix used on the certificate and key database file. This argument is provided to support legacy servers. Most applications do not use a database prefix.</para></listitem>
301       </varlistentry>
302
303       <varlistentry>
304         <term>-p phone</term>
305         <listitem><para>Specify a contact telephone number to include in new certificates or certificate requests. Bracket this string with quotation marks if it contains spaces.</para></listitem>
306       </varlistentry>
307
308       <varlistentry>
309         <term>-q pqgfile or curve-name</term>
310         <listitem>
311         <para>Read an alternate PQG value from the specified file when generating DSA key pairs. If this argument is not used, <command>certutil</command> generates its own PQG value. PQG files are created with a separate DSA utility.</para>
312         <para>Elliptic curve name is one of the ones from SUITE B: nistp256, nistp384, nistp521</para>
313         <para>
314            If NSS has been compiled with support curves outside of SUITE B:
315               sect163k1, nistk163, sect163r1, sect163r2,            
316               nistb163,  sect193r1, sect193r2, sect233k1, nistk233,            
317               sect233r1, nistb233, sect239k1, sect283k1, nistk283,            
318               sect283r1, nistb283, sect409k1, nistk409, sect409r1,            
319               nistb409,  sect571k1, nistk571, sect571r1, nistb571,            
320               secp160k1, secp160r1, secp160r2, secp192k1, secp192r1,            
321               nistp192,  secp224k1, secp224r1, nistp224, secp256k1,            
322               secp256r1, secp384r1, secp521r1,       
323               prime192v1, prime192v2, prime192v3,          
324               prime239v1, prime239v2, prime239v3, c2pnb163v1,             
325               c2pnb163v2, c2pnb163v3, c2pnb176v1, c2tnb191v1,             
326               c2tnb191v2, c2tnb191v3,              
327               c2pnb208w1, c2tnb239v1, c2tnb239v2, c2tnb239v3,             
328               c2pnb272w1, c2pnb304w1,             
329               c2tnb359w1, c2pnb368w1, c2tnb431r1, secp112r1,             
330               secp112r2, secp128r1, secp128r2, sect113r1, sect113r2            
331               sect131r1, sect131r2    
332         </para>
333
334         </listitem>
335         
336       </varlistentry>
337
338       <varlistentry>
339         <term>-r </term>
340         <listitem><para>Display a certificate's binary DER encoding when listing information about that certificate with the -L option.</para></listitem>
341       </varlistentry>
342
343       <varlistentry>
344         <term>-s subject</term>
345         <listitem><para>Identify a particular certificate owner for new certificates or certificate requests. Bracket this string with quotation marks if it contains spaces. The subject identification format follows RFC #1485.</para></listitem>
346       </varlistentry>
347
348       <varlistentry>
349         <term>-t trustargs</term>
350         <listitem><para>Specify the trust attributes to modify in an existing certificate or to apply to a certificate when creating it or adding it to a database. There are three available trust categories for each certificate, expressed in the order <emphasis>SSL, email, object signing</emphasis> for each trust setting. In each category position, use none, any, or all
351 of the attribute codes: 
352         </para>
353         <itemizedlist>
354         <listitem>
355         <para>
356                 <command>p</command> - Valid peer
357         </para>
358         </listitem>
359         <listitem>
360         <para>
361                 <command>P</command> - Trusted peer (implies p)
362         </para>
363         </listitem>
364         <listitem>
365         <para>
366                 <command>c</command> - Valid CA
367         </para>
368         </listitem>
369         <listitem>
370         <para>
371                 <command>T</command> - Trusted CA (implies c)
372         </para>
373         </listitem>
374         <listitem>
375         <para>
376                 <command>C</command> - trusted CA for client authentication (ssl server only)
377         </para>
378         </listitem>
379         <listitem>
380         <para>
381                 <command>u</command> - user
382         </para>
383         </listitem>
384         </itemizedlist>
385         <para>
386                 The attribute codes for the categories are separated by commas, and the entire set of attributes enclosed by quotation marks. For example:
387         </para>
388 <para><command>-t "TCu,Cu,Tu"</command></para>
389         <para>
390         Use the -L option to see a list of the current certificates and trust attributes in a certificate database. </para></listitem>
391       </varlistentry>
392
393       <varlistentry>
394         <term>-u certusage</term>
395         <listitem><para>Specify a usage context to apply when validating a certificate with the -V option.</para><para>The contexts are the following:</para>
396         <itemizedlist>
397         <listitem>
398 <para><command>C</command> (as an SSL client)</para>
399         </listitem>
400         <listitem>
401 <para><command>V</command> (as an SSL server)</para>
402         </listitem>
403         <listitem>
404 <para><command>L</command> (as an SSL CA)</para>
405         </listitem>
406         <listitem>
407 <para><command>A</command> (as Any CA)</para>
408         </listitem>
409         <listitem>
410 <para><command>Y</command> (Verify CA)</para>
411         </listitem>
412         <listitem>
413 <para><command>S</command> (as an email signer)</para>
414         </listitem>
415         <listitem>
416 <para><command>R</command> (as an email recipient)</para>
417         </listitem>
418         <listitem>
419 <para><command>O</command> (as an OCSP status responder)</para>
420         </listitem>
421         <listitem>
422 <para><command>J</command> (as an object signer)</para>
423         </listitem>
424         </itemizedlist></listitem>
425       </varlistentry>
426
427       <varlistentry>
428         <term>-v valid-months</term>
429         <listitem><para>Set the number of months a new certificate will be valid. The validity period begins at the current system time unless an offset is added or subtracted with the <option>-w</option> option. If this argument is not used, the default validity period is three months. </para></listitem>
430       </varlistentry>
431
432       <varlistentry>
433         <term>-w offset-months</term>
434         <listitem><para>Set an offset from the current system time, in months, 
435  for the beginning of a certificate's validity period. Use when creating 
436  the certificate or adding it to a database. Express the offset in integers, 
437  using a minus sign (-) to indicate a negative offset. If this argument is 
438  not used, the validity period begins at the current system time. The length 
439  of the validity period is set with the -v argument. </para></listitem>
440       </varlistentry>
441
442       <varlistentry>
443         <term>-X </term>
444         <listitem><para>Force the key and certificate database to open in read-write mode. This is used with the <option>-U</option> and <option>-L</option> command options.</para></listitem>
445       </varlistentry>
446
447       <varlistentry>
448         <term>-x </term>
449         <listitem><para>Use <command>certutil</command> to generate the signature for a certificate being created or added to a database, rather than obtaining a signature from a separate CA.</para></listitem>
450       </varlistentry>
451
452       <varlistentry>
453         <term>-y exp</term>
454         <listitem><para>Set an alternate exponent value to use in generating a new RSA public key for the database, instead of the default value of 65537. The available alternate values are 3 and 17.</para></listitem>
455       </varlistentry>
456
457       <varlistentry>
458         <term>-z noise-file</term>
459         <listitem><para>Read a seed value from the specified file to generate a new private and public key pair. This argument makes it possible to use hardware-generated seed values or manually create a value from the keyboard. The minimum file size is 20 bytes.</para></listitem>
460       </varlistentry>
461
462       <varlistentry>
463         <term>-0 SSO_password</term>
464         <listitem><para>Set a site security officer password on a token.</para></listitem>
465       </varlistentry>
466
467       <varlistentry>
468         <term>-1 | --keyUsage keyword,keyword</term>
469         <listitem><para>Set an X.509 V3 Certificate Type Extension in the certificate. There are several available keywords:</para>
470         <itemizedlist>
471         <listitem>
472         <para>
473                 digitalSignature
474         </para>
475         </listitem>
476         <listitem>
477         <para>
478                 nonRepudiation
479         </para>
480         </listitem>
481         <listitem>
482         <para>
483                 keyEncipherment
484         </para>
485         </listitem>
486         <listitem>
487         <para>
488                 dataEncipherment
489         </para>
490         </listitem>
491         <listitem>
492         <para>
493                 keyAgreement
494         </para>
495         </listitem>
496         <listitem>
497         <para>
498                 certSigning
499         </para>
500         </listitem>
501         <listitem>
502         <para>
503                 crlSigning
504         </para>
505         </listitem>
506         <listitem>
507         <para>
508                 critical
509         </para>
510         </listitem>
511         </itemizedlist>
512 </listitem>
513       </varlistentry>
514
515       <varlistentry>
516         <term>-2 </term>
517         <listitem><para>Add a basic constraint extension to a certificate that is being created or added to a database. This extension supports the certificate chain verification process. <command>certutil</command> prompts for the certificate constraint extension to select.</para>
518 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
519       </varlistentry>
520
521       <varlistentry>
522         <term>-3 </term>
523         <listitem><para>Add an authority key ID extension to a certificate that is being created or added to a database. This extension supports the identification of a particular certificate, from among multiple certificates associated with one subject name, as the correct issuer of a certificate. The Certificate Database Tool will prompt you to select the authority key ID extension.</para>
524 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
525       </varlistentry>
526
527       <varlistentry>
528         <term>-4 </term>
529         <listitem><para>Add a CRL distribution point extension to a certificate that is being created or added to a database. This extension identifies the URL of a certificate's associated certificate revocation list (CRL). <command>certutil</command> prompts for the URL.</para>
530 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
531       </varlistentry>
532
533       <varlistentry>
534         <term>-5 | --nsCertType keyword,keyword</term>
535         <listitem><para>Add an X.509 V3 certificate type extension to a certificate that is being created or added to the database. There are several available keywords:</para>
536         <itemizedlist>
537         <listitem>
538         <para>
539                 sslClient
540         </para>
541         </listitem>
542         <listitem>
543         <para>
544                 sslServer
545         </para>
546         </listitem>
547         <listitem>
548         <para>
549                 smime
550         </para>
551         </listitem>
552         <listitem>
553         <para>
554                 objectSigning
555         </para>
556         </listitem>
557         <listitem>
558         <para>
559                 sslCA
560         </para>
561         </listitem>
562         <listitem>
563         <para>
564                 smimeCA
565         </para>
566         </listitem>
567         <listitem>
568         <para>
569                 objectSigningCA
570         </para>
571         </listitem>
572         <listitem>
573         <para>
574                 critical
575         </para>
576         </listitem>
577         </itemizedlist>
578
579 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
580       </varlistentry>
581
582       <varlistentry>
583         <term>-6 | --extKeyUsage keyword,keyword</term>
584         <listitem><para>Add an extended key usage extension to a certificate that is being created or added to the database. Several keywords are available:</para>
585         <itemizedlist>
586         <listitem>
587         <para>
588                 serverAuth
589         </para>
590         </listitem>
591         <listitem>
592         <para>
593                 clientAuth
594         </para>
595         </listitem>
596         <listitem>
597         <para>
598                 codeSigning
599         </para>
600         </listitem>
601         <listitem>
602         <para>
603                 emailProtection
604         </para>
605         </listitem>
606         <listitem>
607         <para>
608                 timeStamp
609         </para>
610         </listitem>
611         <listitem>
612         <para>
613                 ocspResponder
614         </para>
615         </listitem>
616         <listitem>
617         <para>
618                 stepUp
619         </para>
620         </listitem>
621         <listitem>
622         <para>
623                 msTrustListSign
624         </para>
625         </listitem>
626         <listitem>
627         <para>
628                 critical
629         </para>
630         </listitem>
631         </itemizedlist>
632 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
633       </varlistentry>
634
635       <varlistentry>
636         <term>-7 emailAddrs</term>
637         <listitem><para>Add a comma-separated list of email addresses to the subject alternative name extension of a certificate or certificate request that is being created or added to the database. Subject alternative name extensions are described in Section 4.2.1.7 of RFC 3280.</para></listitem>
638       </varlistentry>
639
640       <varlistentry>
641         <term>-8 dns-names</term>
642         <listitem><para>Add a comma-separated list of DNS names to the subject alternative name extension of a certificate or certificate request that is being created or added to the database. Subject alternative name extensions are described in Section 4.2.1.7 of RFC 3280.</para></listitem>
643       </varlistentry>
644
645       <varlistentry>
646         <term>--extAIA</term>
647         <listitem><para>Add the Authority Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
648       </varlistentry>
649
650       <varlistentry>
651         <term>--extSIA</term>
652         <listitem><para>Add the Subject Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
653       </varlistentry>
654
655       <varlistentry>
656         <term>--extCP</term>
657         <listitem><para>Add the Certificate Policies extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
658       </varlistentry>
659
660       <varlistentry>
661         <term>--extPM</term>
662         <listitem><para>Add the Policy Mappings extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
663       </varlistentry>
664
665       <varlistentry>
666         <term>--extPC</term>
667         <listitem><para>Add the Policy Constraints extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
668       </varlistentry>
669
670       <varlistentry>
671         <term>--extIA</term>
672         <listitem><para>Add the Inhibit Any Policy Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
673       </varlistentry>
674
675       <varlistentry>
676         <term>--extSKID</term>
677         <listitem><para>Add the Subject Key ID extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
678       </varlistentry>
679
680       <varlistentry>
681         <term>--extNC</term>
682         <listitem><para>Add a Name Constraint extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
683       </varlistentry>
684
685       <varlistentry>
686         <term>--extSAN type:name[,type:name]...</term>
687         <listitem><para>
688 Create a Subject Alt Name extension with one or multiple names.
689           </para>
690           <para>
691 -type: directory, dn, dns, edi, ediparty, email, ip, ipaddr, other, registerid, rfc822, uri, x400, x400addr
692         </para>
693         </listitem>
694       </varlistentry>
695
696       <varlistentry>
697         <term>--empty-password</term>
698         <listitem><para>Use empty password when creating new certificate database with -N.</para></listitem>
699       </varlistentry>
700
701       <varlistentry>
702         <term>--keyAttrFlags attrflags</term>
703         <listitem><para>
704 PKCS #11 key Attributes. Comma separated list of key attribute flags, selected from the following list of choices: {token | session} {public | private} {sensitive | insensitive} {modifiable | unmodifiable} {extractable | unextractable}</para></listitem>
705       </varlistentry>
706
707       <varlistentry>
708         <term>--keyOpFlagsOn opflags</term>
709         <term>--keyOpFlagsOff opflags</term>
710         <listitem><para>
711 PKCS #11 key Operation Flags.
712 Comma separated list of one or more of the following:
713 {token | session} {public | private} {sensitive | insensitive} {modifiable | unmodifiable} {extractable | unextractable}
714           </para></listitem>
715       </varlistentry>
716
717       <varlistentry>
718         <term>--source-dir certdir</term>
719         <listitem><para>Identify the certificate database directory to upgrade.</para></listitem>
720       </varlistentry>
721
722       <varlistentry>
723         <term>--source-prefix certdir</term>
724         <listitem><para>Give the prefix of the certificate and key databases to upgrade.</para></listitem>
725       </varlistentry>
726
727       <varlistentry>
728         <term>--upgrade-id uniqueID</term>
729         <listitem><para>Give the unique ID of the database to upgrade.</para></listitem>
730       </varlistentry>
731
732       <varlistentry>
733         <term>--upgrade-token-name name</term>
734         <listitem><para>Set the name of the token to use while it is being upgraded.</para></listitem>
735       </varlistentry>
736
737       <varlistentry>
738         <term>-@ pwfile</term>
739         <listitem><para>Give the name of a password file to use for the database being upgraded.</para></listitem>
740       </varlistentry>
741
742     </variablelist>
743   </refsection>
744
745   <refsection id="basic-usage">
746     <title>Usage and Examples</title>
747         <para>
748                 Most of the command options in the examples listed here have more arguments available. The arguments included in these examples are the most common ones or are used to illustrate a specific scenario. Use the <option>-H</option> option to show the complete list of arguments for each command option.
749         </para>
750         <para><command>Creating New Security Databases</command></para>
751         <para>
752                 Certificates, keys, and security modules related to managing certificates are stored in three related databases:
753         </para>
754         <itemizedlist>
755         <listitem>
756         <para>
757                 cert8.db or cert9.db
758         </para>
759         </listitem>
760         <listitem>
761         <para>
762                 key3.db or key4.db
763         </para>
764         </listitem>
765         <listitem>
766         <para>
767                 secmod.db or pkcs11.txt
768         </para>
769         </listitem>
770         </itemizedlist>
771         <para>
772                 These databases must be created before certificates or keys can be generated.
773         </para>
774 <programlisting>certutil -N -d [sql:]directory</programlisting>
775
776         <para><command>Creating a Certificate Request</command></para>
777         <para>
778                 A certificate request contains most or all of the information that is used to generate the final certificate. This request is submitted separately to a certificate authority and is then approved by some mechanism (automatically or by human review). Once the request is approved, then the certificate is generated.
779         </para>
780 <programlisting>$ certutil -R -k key-type-or-id [-q pqgfile|curve-name] -g key-size -s subject [-h tokenname] -d [sql:]directory [-p phone] [-o output-file] [-a]</programlisting>
781         <para>
782                 The <option>-R</option> command options requires four arguments:
783         </para>
784         <itemizedlist>
785         <listitem>
786         <para>
787                 <option>-k</option> to specify either the key type to generate or, when renewing a certificate, the existing key pair to use
788         </para>
789         </listitem>
790         <listitem>
791         <para>
792                 <option>-g</option> to set the keysize of the key to generate
793         </para>
794         </listitem>
795         <listitem>
796         <para>
797                 <option>-s</option> to set the subject name of the certificate
798         </para>
799         </listitem>
800         <listitem>
801         <para>
802                 <option>-d</option> to give the security database directory
803         </para>
804         </listitem>
805         </itemizedlist>
806         <para>
807                 The new certificate request can be output in ASCII format (<option>-a</option>) or can be written to a specified file (<option>-o</option>).
808         </para>
809         <para>
810                 For example:
811         </para>
812 <programlisting>$ certutil -R -k rsa -g 1024 -s "CN=John Smith,O=Example Corp,L=Mountain View,ST=California,C=US" -d sql:$HOME/nssdb -p 650-555-0123 -a -o cert.cer
813
814 Generating key.  This may take a few moments...
815
816 </programlisting>
817
818         <para><command>Creating a Certificate</command></para>
819         <para>
820                 A valid certificate must be issued by a trusted CA. This can be done by specifying a CA certificate (<option>-c</option>) that is stored in the certificate database. If a CA key pair is not available, you can create a self-signed certificate using the <option>-x</option> argument with the <option>-S</option> command option.
821         </para>
822 <programlisting>$ certutil -S -k rsa|dsa|ec -n certname -s subject [-c issuer |-x] -t trustargs -d [sql:]directory [-m serial-number] [-v valid-months] [-w offset-months] [-p phone] [-1] [-2] [-3] [-4] [-5 keyword] [-6 keyword] [-7 emailAddress] [-8 dns-names] [--extAIA] [--extSIA] [--extCP] [--extPM] [--extPC] [--extIA] [--extSKID]</programlisting>
823         <para>
824                 The series of numbers and <option>--ext*</option> options set certificate extensions that can be added to the certificate when it is generated by the CA. Interactive prompts will result.
825         </para>
826         <para>
827                 For example, this creates a self-signed certificate:
828         </para>
829 <programlisting>$ certutil -S -s "CN=Example CA" -n my-ca-cert -x -t "C,C,C" -1 -2 -5 -m 3650</programlisting>
830         <para>
831 The interative prompts for key usage and whether any extensions are critical and responses have been ommitted for brevity.
832         </para>
833         <para>
834                 From there, new certificates can reference the self-signed certificate:
835         </para>
836 <programlisting>$ certutil -S -s "CN=My Server Cert" -n my-server-cert -c "my-ca-cert" -t "u,u,u" -1 -5 -6 -8 -m 730</programlisting>
837
838         <para><command>Generating a Certificate from a Certificate Request</command></para>
839         <para>
840                 When a certificate request is created, a certificate can be generated by using the request and then referencing a certificate authority signing certificate (the <emphasis>issuer</emphasis> specified in the <option>-c</option> argument). The issuing certificate must be in the certificate database in the specified directory.
841         </para>
842 <programlisting>certutil -C -c issuer -i cert-request-file -o output-file [-m serial-number] [-v valid-months] [-w offset-months] -d [sql:]directory [-1] [-2] [-3] [-4] [-5 keyword] [-6 keyword] [-7 emailAddress] [-8 dns-names]</programlisting>
843         <para>
844                 For example:
845         </para>
846 <programlisting>$ certutil -C -c "my-ca-cert" -i /home/certs/cert.req -o cert.cer -m 010 -v 12 -w 1 -d sql:$HOME/nssdb -1 nonRepudiation,dataEncipherment -5 sslClient -6 clientAuth -7 jsmith@example.com</programlisting>
847
848         <para><command>Listing Certificates</command></para>
849         <para>
850                 The <option>-L</option> command option lists all of the certificates listed in the certificate database. The path to the directory (<option>-d</option>) is required.
851         </para>
852 <programlisting>$ certutil -L -d sql:/home/my/sharednssdb
853
854 Certificate Nickname                                         Trust Attributes
855                                                              SSL,S/MIME,JAR/XPI
856
857 CA Administrator of Instance pki-ca1's Example Domain ID     u,u,u
858 TPS Administrator's Example Domain ID                        u,u,u
859 Google Internet Authority                                    ,,   
860 Certificate Authority - Example Domain                       CT,C,C</programlisting>
861         <para>
862                 Using additional arguments with <option>-L</option> can return and print the information for a single, specific certificate. For example, the <option>-n</option> argument passes the certificate name, while the <option>-a</option> argument prints the certificate in ASCII format:
863         </para>
864 <programlisting>
865 $ certutil -L -d sql:$HOME/nssdb -a -n my-ca-cert
866 -----BEGIN CERTIFICATE-----
867 MIIB1DCCAT2gAwIBAgICDkIwDQYJKoZIhvcNAQEFBQAwFTETMBEGA1UEAxMKRXhh
868 bXBsZSBDQTAeFw0xMzAzMTMxOTEwMjlaFw0xMzA2MTMxOTEwMjlaMBUxEzARBgNV
869 BAMTCkV4YW1wbGUgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJ4Kzqvz
870 JyBVgFqDXRYSyTBNw1DrxUU/3GvWA/ngjAwHEv0Cul/6sO/gsCvnABHiH6unns6x
871 XRzPORlC2WY3gkk7vmlsLvYpyecNazAi/NAwVnU/66HOsaoVFWE+gBQo99UrN2yk
872 0BiK/GMFlLm5dXQROgA9ZKKyFdI0LIXtf6SbAgMBAAGjMzAxMBEGCWCGSAGG+EIB
873 AQQEAwIHADAMBgNVHRMEBTADAQH/MA4GA1UdDwEB/wQEAwICBDANBgkqhkiG9w0B
874 AQUFAAOBgQA6chkzkACN281d1jKMrc+RHG2UMaQyxiteaLVZO+Ro1nnRUvseDf09
875 XKYFwPMJjWCihVku6bw/ihZfuMHhxK22Nue6inNQ6eDu7WmrqL8z3iUrQwxs+WiF
876 ob2rb8XRVVJkzXdXxlk4uo3UtNvw8sAz7sWD71qxKaIHU5q49zijfg==
877 -----END CERTIFICATE-----
878 </programlisting>
879 <para>For a human-readable display</para>
880 <programlisting>$ certutil -L -d sql:$HOME/nssdb -n my-ca-cert
881 Certificate:
882     Data:
883         Version: 3 (0x2)
884         Serial Number: 3650 (0xe42)
885         Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
886         Issuer: "CN=Example CA"
887         Validity:
888             Not Before: Wed Mar 13 19:10:29 2013
889             Not After : Thu Jun 13 19:10:29 2013
890         Subject: "CN=Example CA"
891         Subject Public Key Info:
892             Public Key Algorithm: PKCS #1 RSA Encryption
893             RSA Public Key:
894                 Modulus:
895                     9e:0a:ce:ab:f3:27:20:55:80:5a:83:5d:16:12:c9:30:
896                     4d:c3:50:eb:c5:45:3f:dc:6b:d6:03:f9:e0:8c:0c:07:
897                     12:fd:02:ba:5f:fa:b0:ef:e0:b0:2b:e7:00:11:e2:1f:
898                     ab:a7:9e:ce:b1:5d:1c:cf:39:19:42:d9:66:37:82:49:
899                     3b:be:69:6c:2e:f6:29:c9:e7:0d:6b:30:22:fc:d0:30:
900                     56:75:3f:eb:a1:ce:b1:aa:15:15:61:3e:80:14:28:f7:
901                     d5:2b:37:6c:a4:d0:18:8a:fc:63:05:94:b9:b9:75:74:
902                     11:3a:00:3d:64:a2:b2:15:d2:34:2c:85:ed:7f:a4:9b
903                 Exponent: 65537 (0x10001)
904         Signed Extensions:
905             Name: Certificate Type
906             Data: none
907
908             Name: Certificate Basic Constraints
909             Data: Is a CA with no maximum path length.
910
911             Name: Certificate Key Usage
912             Critical: True
913             Usages: Certificate Signing
914
915     Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
916     Signature:
917         3a:72:19:33:90:00:8d:db:cd:5d:d6:32:8c:ad:cf:91:
918         1c:6d:94:31:a4:32:c6:2b:5e:68:b5:59:3b:e4:68:d6:
919         79:d1:52:fb:1e:0d:fd:3d:5c:a6:05:c0:f3:09:8d:60:
920         a2:85:59:2e:e9:bc:3f:8a:16:5f:b8:c1:e1:c4:ad:b6:
921         36:e7:ba:8a:73:50:e9:e0:ee:ed:69:ab:a8:bf:33:de:
922         25:2b:43:0c:6c:f9:68:85:a1:bd:ab:6f:c5:d1:55:52:
923         64:cd:77:57:c6:59:38:ba:8d:d4:b4:db:f0:f2:c0:33:
924         ee:c5:83:ef:5a:b1:29:a2:07:53:9a:b8:f7:38:a3:7e
925     Fingerprint (MD5):
926         86:D8:A5:8B:8A:26:BE:9E:17:A8:7B:66:10:6B:27:80
927     Fingerprint (SHA1):
928         48:78:09:EF:C5:D4:0C:BD:D2:64:45:59:EB:03:13:15:F7:A9:D6:F7
929
930     Certificate Trust Flags:
931         SSL Flags:
932             Valid CA
933             Trusted CA
934             User
935         Email Flags:
936             Valid CA
937             Trusted CA
938             User
939         Object Signing Flags:
940             Valid CA
941             Trusted CA
942             User
943
944 </programlisting>
945
946         <para><command>Listing Keys</command></para>
947         <para>
948                 Keys are the original material used to encrypt certificate data. The keys generated for certificates are stored separately, in the key database. 
949         </para>
950         <para>
951                 To list all keys in the database, use the <option>-K</option> command option and the (required) <option>-d</option> argument to give the path to the directory.
952         </para>
953 <programlisting>$ certutil -K -d sql:$HOME/nssdb
954 certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services                  "
955 &lt; 0> rsa      455a6673bde9375c2887ec8bf8016b3f9f35861d   Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID
956 &lt; 1> rsa      40defeeb522ade11090eacebaaf1196a172127df   Example Domain Administrator Cert
957 &lt; 2> rsa      1d0b06f44f6c03842f7d4f4a1dc78b3bcd1b85a5   John Smith user cert</programlisting>
958         <para>
959                 There are ways to narrow the keys listed in the search results:
960         </para>
961         <itemizedlist>
962         <listitem>
963         <para>
964                 To return a specific key, use the <option>-n</option> <emphasis>name</emphasis> argument with the name of the key.
965         </para>
966         </listitem>
967         <listitem>
968         <para>
969                 If there are multiple security devices loaded, then the <option>-h</option> <emphasis>tokenname</emphasis> argument can search a specific token or all tokens.
970         </para>
971         </listitem>
972         <listitem>
973         <para>
974                 If there are multiple key types available, then the <option>-k</option> <emphasis>key-type</emphasis> argument can search a specific type of key, like RSA, DSA, or ECC. 
975         </para>
976         </listitem>
977         </itemizedlist>
978
979         <para><command>Listing Security Modules</command></para>
980         <para>
981                 The devices that can be used to store certificates -- both internal databases and external devices like smart cards -- are recognized and used by loading security modules. The <option>-U</option> command option lists all of the security modules listed in the <filename>secmod.db</filename> database. The path to the directory (<option>-d</option>) is required.
982         </para>
983 <programlisting>$ certutil -U -d sql:/home/my/sharednssdb
984
985     slot: NSS User Private Key and Certificate Services                  
986    token: NSS Certificate DB
987
988     slot: NSS Internal Cryptographic Services                            
989    token: NSS Generic Crypto Services</programlisting>
990
991         <para><command>Adding Certificates to the Database</command></para>
992         <para>
993                 Existing certificates or certificate requests can be added manually to the certificate database, even if they were generated elsewhere. This uses the <option>-A</option> command option.
994         </para>
995 <programlisting>certutil -A -n certname -t trustargs -d [sql:]directory [-a] [-i input-file]</programlisting>
996         <para>
997                 For example:
998         </para>
999 <programlisting>$ certutil -A -n "CN=My SSL Certificate" -t "u,u,u" -d sql:/home/my/sharednssdb -i /home/example-certs/cert.cer</programlisting>
1000         <para>
1001                 A related command option, <option>-E</option>, is used specifically to add email certificates to the certificate database. The <option>-E</option> command has the same arguments as the <option>-A</option> command. The trust arguments for certificates have the format <emphasis>SSL,S/MIME,Code-signing</emphasis>, so the middle trust settings relate most to email certificates (though the others can be set). For example:
1002         </para>
1003 <programlisting>$ certutil -E -n "CN=John Smith Email Cert" -t ",Pu," -d sql:/home/my/sharednssdb -i /home/example-certs/email.cer</programlisting>
1004
1005         <para><command>Deleting Certificates to the Database</command></para>
1006         <para>
1007                 Certificates can be deleted from a database using the <option>-D</option> option. The only required options are to give the security database directory and to identify the certificate nickname.
1008         </para>
1009 <programlisting>certutil -D -d [sql:]directory -n "nickname"</programlisting>
1010         <para>
1011                 For example:
1012         </para>
1013 <programlisting>$ certutil -D -d sql:/home/my/sharednssdb -n "my-ssl-cert"</programlisting>
1014
1015         <para><command>Validating Certificates</command></para>
1016         <para>
1017                 A certificate contains an expiration date in itself, and expired certificates are easily rejected. However, certificates can also be revoked before they hit their expiration date. Checking whether a certificate has been revoked requires validating the certificate. Validation can also be used to ensure that the certificate is only used for the purposes it was initially issued for. Validation is carried out by the <option>-V</option> command option.
1018         </para>
1019 <programlisting>certutil -V -n certificate-name [-b time] [-e] [-u cert-usage] -d [sql:]directory</programlisting>
1020         <para>
1021                 For example, to validate an email certificate:
1022         </para>
1023 <programlisting>$ certutil -V -n "John Smith's Email Cert" -e -u S,R -d sql:/home/my/sharednssdb</programlisting>
1024
1025         <para><command>Modifying Certificate Trust Settings</command></para>
1026         <para>
1027                 The trust settings (which relate to the operations that a certificate is allowed to be used for) can be changed after a certificate is created or added to the database. This is especially useful for CA certificates, but it can be performed for any type of certificate.
1028         </para>
1029 <programlisting>certutil -M -n certificate-name -t trust-args -d [sql:]directory</programlisting>
1030         <para>
1031                 For example:
1032         </para>
1033 <programlisting>$ certutil -M -n "My CA Certificate" -d sql:/home/my/sharednssdb -t "CTu,CTu,CTu"</programlisting>
1034
1035         <para><command>Printing the Certificate Chain</command></para>
1036         <para>
1037                 Certificates can be issued in <emphasis>chains</emphasis> because every certificate authority itself has a certificate; when a CA issues a certificate, it essentially stamps that certificate with its own fingerprint. The <option>-O</option> prints the full chain of a certificate, going from the initial CA (the root CA) through ever intermediary CA to the actual certificate. For example, for an email certificate with two CAs in the chain:
1038         </para>
1039 <programlisting>$ certutil -d sql:/home/my/sharednssdb -O -n "jsmith@example.com"
1040 "Builtin Object Token:Thawte Personal Freemail CA" [E=personal-freemail@thawte.com,CN=Thawte Personal Freemail CA,OU=Certification Services Division,O=Thawte Consulting,L=Cape Town,ST=Western Cape,C=ZA]
1041
1042   "Thawte Personal Freemail Issuing CA - Thawte Consulting" [CN=Thawte Personal Freemail Issuing CA,O=Thawte Consulting (Pty) Ltd.,C=ZA]
1043
1044     "(null)" [E=jsmith@example.com,CN=Thawte Freemail Member]</programlisting>
1045
1046         <para><command>Resetting a Token</command></para>
1047         <para>
1048                 The device which stores certificates -- both external hardware devices and internal software databases -- can be blanked and reused. This operation is performed on the device which stores the data, not directly on the security databases, so the location must be referenced through the token name (<option>-h</option>) as well as any directory path. If there is no external token used, the default value is internal.
1049         </para>
1050 <programlisting>certutil -T -d [sql:]directory -h token-name -0 security-officer-password</programlisting>
1051         <para>
1052                 Many networks have dedicated personnel who handle changes to security tokens (the security officer). This person must supply the password to access the specified token. For example:
1053         </para>
1054 <programlisting>$ certutil -T -d sql:/home/my/sharednssdb -h nethsm -0 secret</programlisting>
1055
1056         <para><command>Upgrading or Merging the Security Databases</command></para>
1057         <para>
1058                 Many networks or applications may be using older BerkeleyDB versions of the certificate database (<filename>cert8.db</filename>). Databases can be upgraded to the new SQLite version of the database (<filename>cert9.db</filename>) using the <option>--upgrade-merge</option> command option or existing databases can be merged with the new <filename>cert9.db</filename> databases using the <option>---merge</option> command.
1059         </para>
1060         <para>
1061                 The <option>--upgrade-merge</option> command must give information about the original database and then use the standard arguments (like <option>-d</option>) to give the information about the new databases. The command also requires information that the tool uses for the process to upgrade and write over the original database.
1062         </para>
1063 <programlisting>certutil --upgrade-merge -d [sql:]directory [-P dbprefix] --source-dir directory --source-prefix dbprefix --upgrade-id id --upgrade-token-name name [-@ password-file]</programlisting>
1064         <para>
1065                 For example:
1066         </para>
1067 <programlisting>$ certutil --upgrade-merge -d sql:/home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix serverapp- --upgrade-id 1 --upgrade-token-name internal</programlisting>
1068         <para>
1069                 The <option>--merge</option> command only requires information about the location of the original database; since it doesn't change the format of the database, it can write over information without performing interim step.
1070         </para>
1071 <programlisting>certutil --merge -d [sql:]directory [-P dbprefix] --source-dir directory --source-prefix dbprefix [-@ password-file]</programlisting>
1072         <para>
1073                 For example:
1074         </para>
1075 <programlisting>$ certutil --merge -d sql:/home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix serverapp-</programlisting>
1076
1077         <para><command>Running certutil Commands from a Batch File</command></para>
1078         <para>
1079                 A series of commands can be run sequentially from a text file with the <option>-B</option> command option. The only argument for this specifies the input file.
1080         </para>
1081 <programlisting>$ certutil -B -i /path/to/batch-file</programlisting>
1082   </refsection>
1083
1084 <refsection id="databases"><title>NSS Database Types</title>
1085 <para>NSS originally used BerkeleyDB databases to store security information. 
1086 The last versions of these <emphasis>legacy</emphasis> databases are:</para>
1087 <itemizedlist>
1088         <listitem>
1089                 <para>
1090                         cert8.db for certificates
1091                 </para>
1092         </listitem>
1093         <listitem>
1094                 <para>
1095                         key3.db for keys
1096                 </para>
1097         </listitem>
1098         <listitem>
1099                 <para>
1100                         secmod.db for PKCS #11 module information
1101                 </para>
1102         </listitem>
1103 </itemizedlist>
1104
1105 <para>BerkeleyDB has performance limitations, though, which prevent it from being easily used by multiple applications simultaneously. NSS has 
1106 some flexibility that allows applications to use their own, independent database engine while keeping a shared database and working around the access issues. Still, NSS
1107 requires more flexibility to provide a truly shared security database.</para>
1108
1109 <para>In 2009, NSS introduced a new set of databases that are SQLite databases rather than 
1110 BerkeleyDB. These new databases provide more accessibility and performance:</para>
1111 <itemizedlist>
1112         <listitem>
1113                 <para>
1114                         cert9.db for certificates
1115                 </para>
1116         </listitem>
1117         <listitem>
1118                 <para>
1119                         key4.db for keys
1120                 </para>
1121         </listitem>
1122         <listitem>
1123                 <para>
1124                         pkcs11.txt, a listing of all of the PKCS #11 modules, contained in a new subdirectory in the security databases directory
1125                 </para>
1126         </listitem>
1127 </itemizedlist>
1128
1129 <para>Because the SQLite databases are designed to be shared, these are the <emphasis>shared</emphasis> database type. The shared database type is preferred; the legacy format is included for backward compatibility.</para>
1130
1131 <para>By default, the tools (<command>certutil</command>, <command>pk12util</command>, <command>modutil</command>) assume that the given security databases follow the more common legacy type. 
1132 Using the SQLite databases must be manually specified by using the <command>sql:</command> prefix with the given security directory. For example:</para>
1133
1134 <programlisting>$ certutil -L -d sql:/home/my/sharednssdb</programlisting>
1135
1136 <para>To set the shared database type as the default type for the tools, set the <envar>NSS_DEFAULT_DB_TYPE</envar> environment variable to <envar>sql</envar>:</para>
1137 <programlisting>export NSS_DEFAULT_DB_TYPE="sql"</programlisting>
1138
1139 <para>This line can be set added to the <filename>~/.bashrc</filename> file to make the change permanent.</para>
1140
1141 <para>Most applications do not use the shared database by default, but they can be configured to use them. For example, this how-to article covers how to configure Firefox and Thunderbird to use the new shared NSS databases:</para>
1142 <itemizedlist>
1143         <listitem>
1144                 <para>
1145                         https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
1146         </listitem>
1147 </itemizedlist>
1148 <para>For an engineering draft on the changes in the shared NSS databases, see the NSS project wiki:</para>
1149 <itemizedlist>
1150         <listitem>
1151                 <para>
1152                         https://wiki.mozilla.org/NSS_Shared_DB
1153                 </para>
1154         </listitem>
1155 </itemizedlist>
1156 </refsection>
1157
1158
1159   <refsection id="seealso">
1160     <title>See Also</title>
1161     <para>pk12util (1)</para>
1162     <para>modutil (1)</para>
1163     <para><command>certutil</command> has arguments or operations that use features defined in several IETF RFCs.</para>
1164         <itemizedlist>
1165         <listitem>
1166         <para>
1167                 http://tools.ietf.org/html/rfc5280
1168         </para>
1169         </listitem>
1170         <listitem>
1171         <para>
1172                 http://tools.ietf.org/html/rfc1113
1173         </para>
1174         </listitem>
1175         <listitem>
1176         <para>
1177                 http://tools.ietf.org/html/rfc1485
1178         </para>
1179         </listitem>
1180         </itemizedlist>
1181
1182         <para>The NSS wiki has information on the new database design and how to configure applications to use it.</para>
1183         <itemizedlist>
1184         <listitem>
1185                 <para>
1186                         https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
1187         </listitem>
1188         <listitem>
1189                 <para>
1190                         https://wiki.mozilla.org/NSS_Shared_DB
1191                 </para>
1192         </listitem>
1193         </itemizedlist>
1194   </refsection>
1195
1196 <!-- don't change -->
1197   <refsection id="resources">
1198     <title>Additional Resources</title>
1199         <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>
1200         <para>Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto</para>
1201         <para>IRC: Freenode at #dogtag-pki</para>
1202   </refsection>
1203
1204 <!-- fill in your name first; keep the other names for reference -->
1205   <refsection id="authors">
1206     <title>Authors</title>
1207     <para>The NSS tools were written and maintained by developers with Netscape, Red Hat,  Sun, Oracle, Mozilla, and Google.</para>
1208     <para>
1209         Authors: Elio Maldonado &lt;emaldona@redhat.com>, Deon Lackey &lt;dlackey@redhat.com>.
1210     </para>
1211   </refsection>
1212
1213 <!-- don't change -->
1214   <refsection id="license">
1215     <title>LICENSE</title>
1216     <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/.
1217     </para>
1218   </refsection>
1219
1220 </refentry>