security/nss/doc/certutil.xml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 ]>
     8 <refentry id="certutil">
    10   <refentryinfo>
    11     <date>&date;</date>
    12     <title>NSS Security Tools</title>
    13     <productname>nss-tools</productname>
    14     <productnumber>&version;</productnumber>
    15   </refentryinfo>
    17   <refmeta>
    18     <refentrytitle>CERTUTIL</refentrytitle>
    19     <manvolnum>1</manvolnum>
    20   </refmeta>
    22   <refnamediv>
    23     <refname>certutil</refname>
    24     <refpurpose>Manage keys and certificate in both NSS databases and other NSS tokens</refpurpose>
    25   </refnamediv>
    27   <refsynopsisdiv>
    28     <cmdsynopsis>
    29       <command>certutil</command>
    30       <arg><replaceable>options</replaceable></arg>
    31       <arg>[<replaceable>arguments</replaceable>]</arg>
    32     </cmdsynopsis>
    33   </refsynopsisdiv>
    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>
    41 <refsection id="description">
    42     <title>Description</title>
    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>
    47   </refsection>
    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>
    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>
    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>
    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>
    70       <varlistentry>
    71         <term>-D </term>
    72         <listitem><para>Delete a certificate from the certificate database.</para></listitem>
    73       </varlistentry>
    75       <varlistentry>
    76         <term>-E </term>
    77         <listitem><para>Add an email certificate to the certificate database.</para></listitem>
    78       </varlistentry>
    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>
    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>
    94       <varlistentry>
    95         <term>-H </term>
    96         <listitem><para>Display a list of the command options and arguments.</para></listitem>
    97       </varlistentry>
    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>
   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>
   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>
   115       <varlistentry>
   116         <term>-N</term>
   117         <listitem><para>Create new certificate and key databases.</para></listitem>
   118       </varlistentry>
   120       <varlistentry>
   121         <term>-O </term>
   122         <listitem><para>Print the certificate chain.</para></listitem>
   123       </varlistentry>
   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.
   129 Use the -a argument to specify ASCII output.</para></listitem>
   130       </varlistentry>
   132       <varlistentry>
   133         <term>-S </term>
   134         <listitem><para>Create an individual certificate and add it to a certificate database.</para></listitem>
   135       </varlistentry>
   137       <varlistentry>
   138         <term>-T </term>
   139         <listitem><para>Reset the key database or token.</para></listitem>
   140       </varlistentry>
   142       <varlistentry>
   143         <term>-U </term>
   144         <listitem><para>List all available modules or print a single named module.</para></listitem>
   145       </varlistentry>
   147       <varlistentry>
   148         <term>-V </term>
   149         <listitem><para>Check the validity of a certificate and its attributes.</para></listitem>
   150       </varlistentry>
   152       <varlistentry>
   153         <term>-W </term>
   154         <listitem><para>Change the password to a key database.</para></listitem>
   155       </varlistentry>
   157       <varlistentry>
   158         <term>--merge</term>
   159         <listitem><para>Merge two databases into one.</para></listitem>
   160       </varlistentry>
   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>
   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>
   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>
   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>
   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>
   206       <varlistentry>
   207         <term>-e </term>
   208         <listitem><para>Check a certificate's signature during the process of validating a certificate.</para></listitem>
   209       </varlistentry>
   211       <varlistentry>
   212         <term>--email email-address</term>
   213         <listitem><para>Specify the email address of a certificate to list. Used with the -L command option.</para></listitem>
   214       </varlistentry>
   216       <varlistentry>
   217         <term>-f password-file</term>
   218         <listitem><para>Specify a file that will automatically supply the password to include in a certificate 
   219  or to access a certificate database. This is a plain-text file containing one password. Be sure to prevent 
   220  unauthorized access to this file.</para></listitem>
   221       </varlistentry>
   223       <varlistentry>
   224         <term>-g keysize</term>
   225         <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>
   226       </varlistentry>
   229       <varlistentry>
   230         <term>-h tokenname</term>
   231         <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>
   232       </varlistentry>
   234      <varlistentry>
   235         <term>-i input_file</term>
   236         <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>
   237       </varlistentry>
   239       <varlistentry>
   240         <term>-k key-type-or-id</term>
   241         <listitem>
   242           <para>Specify the type or specific ID of a key.</para>
   243           <para>
   244            The valid key type options are rsa, dsa, ec, or all. The default 
   245            value is rsa. Specifying the type of key can avoid mistakes caused by
   246            duplicate nicknames. Giving a key type generates a new key pair; 
   247            giving the ID of an existing key reuses that key pair (which is 
   248            required to renew certificates).
   249           </para>
   250         </listitem>
   251       </varlistentry>
   253       <varlistentry>
   254         <term>-l </term>
   255         <listitem><para>Display detailed information when validating a certificate with the -V option.</para></listitem>
   256       </varlistentry>
   258       <varlistentry>
   259         <term>-m serial-number</term>
   260         <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>
   261       </varlistentry>
   263       <varlistentry>
   264         <term>-n nickname</term>
   265         <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>
   266       </varlistentry>
   268       <varlistentry>
   269         <term>-o output-file</term>
   270         <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>
   271       </varlistentry>
   273       <varlistentry>
   274         <term>-P dbPrefix</term>
   275         <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>
   276       </varlistentry>
   278       <varlistentry>
   279         <term>-p phone</term>
   280         <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>
   281       </varlistentry>
   283       <varlistentry>
   284         <term>-q pqgfile or curve-name</term>
   285         <listitem>
   286         <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>
   287         <para>Elliptic curve name is one of the ones from SUITE B: nistp256, nistp384, nistp521</para>
   288         <para>
   289            If NSS has been compiled with support curves outside of SUITE B:
   290               sect163k1, nistk163, sect163r1, sect163r2,            
   291               nistb163,  sect193r1, sect193r2, sect233k1, nistk233,            
   292               sect233r1, nistb233, sect239k1, sect283k1, nistk283,            
   293               sect283r1, nistb283, sect409k1, nistk409, sect409r1,            
   294               nistb409,  sect571k1, nistk571, sect571r1, nistb571,            
   295               secp160k1, secp160r1, secp160r2, secp192k1, secp192r1,            
   296               nistp192,  secp224k1, secp224r1, nistp224, secp256k1,            
   297               secp256r1, secp384r1, secp521r1,       
   298               prime192v1, prime192v2, prime192v3,          
   299               prime239v1, prime239v2, prime239v3, c2pnb163v1,             
   300               c2pnb163v2, c2pnb163v3, c2pnb176v1, c2tnb191v1,             
   301               c2tnb191v2, c2tnb191v3,              
   302               c2pnb208w1, c2tnb239v1, c2tnb239v2, c2tnb239v3,             
   303               c2pnb272w1, c2pnb304w1,             
   304               c2tnb359w1, c2pnb368w1, c2tnb431r1, secp112r1,             
   305               secp112r2, secp128r1, secp128r2, sect113r1, sect113r2            
   306               sect131r1, sect131r2    
   307         </para>
   309         </listitem>
   311       </varlistentry>
   313       <varlistentry>
   314         <term>-r </term>
   315         <listitem><para>Display a certificate's binary DER encoding when listing information about that certificate with the -L option.</para></listitem>
   316       </varlistentry>
   318       <varlistentry>
   319         <term>-s subject</term>
   320         <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>
   321       </varlistentry>
   323       <varlistentry>
   324         <term>-t trustargs</term>
   325         <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
   326 of the attribute codes: 
   327 	</para>
   328 	<itemizedlist>
   329 	<listitem>
   330 	<para>
   331 		<command>p</command> - Valid peer
   332 	</para>
   333 	</listitem>
   334 	<listitem>
   335 	<para>
   336 		<command>P</command> - Trusted peer (implies p)
   337 	</para>
   338 	</listitem>
   339 	<listitem>
   340 	<para>
   341 		<command>c</command> - Valid CA
   342 	</para>
   343 	</listitem>
   344 	<listitem>
   345 	<para>
   346 		<command>T</command> - Trusted CA (implies c)
   347 	</para>
   348 	</listitem>
   349 	<listitem>
   350 	<para>
   351 		<command>C</command> - trusted CA for client authentication (ssl server only)
   352 	</para>
   353 	</listitem>
   354 	<listitem>
   355 	<para>
   356 		<command>u</command> - user
   357 	</para>
   358 	</listitem>
   359 	</itemizedlist>
   360 	<para>
   361 		The attribute codes for the categories are separated by commas, and the entire set of attributes enclosed by quotation marks. For example:
   362 	</para>
   363 <para><command>-t "TCu,Cu,Tu"</command></para>
   364 	<para>
   365 	Use the -L option to see a list of the current certificates and trust attributes in a certificate database. </para></listitem>
   366       </varlistentry>
   368       <varlistentry>
   369         <term>-u certusage</term>
   370         <listitem><para>Specify a usage context to apply when validating a certificate with the -V option.</para><para>The contexts are the following:</para>
   371 	<itemizedlist>
   372 	<listitem>
   373 <para><command>C</command> (as an SSL client)</para>
   374 	</listitem>
   375 	<listitem>
   376 <para><command>V</command> (as an SSL server)</para>
   377 	</listitem>
   378 	<listitem>
   379 <para><command>S</command> (as an email signer)</para>
   380 	</listitem>
   381 	<listitem>
   382 <para><command>R</command> (as an email recipient)</para>
   383 	</listitem>
   384 	<listitem>
   385 <para><command>O</command> (as an OCSP status responder)</para>
   386 	</listitem>
   387 	<listitem>
   388 <para><command>J</command> (as an object signer)</para>
   389 	</listitem>
   390 	</itemizedlist></listitem>
   391       </varlistentry>
   393       <varlistentry>
   394         <term>-v valid-months</term>
   395         <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>
   396       </varlistentry>
   398       <varlistentry>
   399         <term>-w offset-months</term>
   400         <listitem><para>Set an offset from the current system time, in months, 
   401  for the beginning of a certificate's validity period. Use when creating 
   402  the certificate or adding it to a database. Express the offset in integers, 
   403  using a minus sign (-) to indicate a negative offset. If this argument is 
   404  not used, the validity period begins at the current system time. The length 
   405  of the validity period is set with the -v argument. </para></listitem>
   406       </varlistentry>
   408       <varlistentry>
   409         <term>-X </term>
   410         <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>
   411       </varlistentry>
   413       <varlistentry>
   414         <term>-x </term>
   415         <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>
   416       </varlistentry>
   418       <varlistentry>
   419         <term>-y exp</term>
   420         <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>
   421       </varlistentry>
   423       <varlistentry>
   424         <term>-z noise-file</term>
   425         <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>
   426       </varlistentry>
   428       <varlistentry>
   429         <term>-0 SSO_password</term>
   430         <listitem><para>Set a site security officer password on a token.</para></listitem>
   431       </varlistentry>
   433       <varlistentry>
   434         <term>-1 | --keyUsage keyword,keyword</term>
   435         <listitem><para>Set an X.509 V3 Certificate Type Extension in the certificate. There are several available keywords:</para>
   436 	<itemizedlist>
   437 	<listitem>
   438 	<para>
   439 		digitalSignature
   440 	</para>
   441 	</listitem>
   442 	<listitem>
   443 	<para>
   444 		nonRepudiation
   445 	</para>
   446 	</listitem>
   447 	<listitem>
   448 	<para>
   449 		keyEncipherment
   450 	</para>
   451 	</listitem>
   452 	<listitem>
   453 	<para>
   454 		dataEncipherment
   455 	</para>
   456 	</listitem>
   457 	<listitem>
   458 	<para>
   459 		keyAgreement
   460 	</para>
   461 	</listitem>
   462 	<listitem>
   463 	<para>
   464 		certSigning
   465 	</para>
   466 	</listitem>
   467 	<listitem>
   468 	<para>
   469 		crlSigning
   470 	</para>
   471 	</listitem>
   472 	<listitem>
   473 	<para>
   474 		critical
   475 	</para>
   476 	</listitem>
   477 	</itemizedlist>
   478 </listitem>
   479       </varlistentry>
   481       <varlistentry>
   482         <term>-2 </term>
   483         <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>
   484 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
   485       </varlistentry>
   487       <varlistentry>
   488         <term>-3 </term>
   489         <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>
   490 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
   491       </varlistentry>
   493       <varlistentry>
   494         <term>-4 </term>
   495         <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>
   496 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
   497       </varlistentry>
   499       <varlistentry>
   500         <term>-5 | --nsCertType keyword,keyword</term>
   501         <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>
   502 	<itemizedlist>
   503 	<listitem>
   504 	<para>
   505 		sslClient
   506 	</para>
   507 	</listitem>
   508 	<listitem>
   509 	<para>
   510 		sslServer
   511 	</para>
   512 	</listitem>
   513 	<listitem>
   514 	<para>
   515 		smime
   516 	</para>
   517 	</listitem>
   518 	<listitem>
   519 	<para>
   520 		objectSigning
   521 	</para>
   522 	</listitem>
   523 	<listitem>
   524 	<para>
   525 		sslCA
   526 	</para>
   527 	</listitem>
   528 	<listitem>
   529 	<para>
   530 		smimeCA
   531 	</para>
   532 	</listitem>
   533 	<listitem>
   534 	<para>
   535 		objectSigningCA
   536 	</para>
   537 	</listitem>
   538 	<listitem>
   539 	<para>
   540 		critical
   541 	</para>
   542 	</listitem>
   543 	</itemizedlist>
   545 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
   546       </varlistentry>
   548       <varlistentry>
   549         <term>-6 | --extKeyUsage keyword,keyword</term>
   550         <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>
   551 	<itemizedlist>
   552 	<listitem>
   553 	<para>
   554 		serverAuth
   555 	</para>
   556 	</listitem>
   557 	<listitem>
   558 	<para>
   559 		clientAuth
   560 	</para>
   561 	</listitem>
   562 	<listitem>
   563 	<para>
   564 		codeSigning
   565 	</para>
   566 	</listitem>
   567 	<listitem>
   568 	<para>
   569 		emailProtection
   570 	</para>
   571 	</listitem>
   572 	<listitem>
   573 	<para>
   574 		timeStamp
   575 	</para>
   576 	</listitem>
   577 	<listitem>
   578 	<para>
   579 		ocspResponder
   580 	</para>
   581 	</listitem>
   582 	<listitem>
   583 	<para>
   584 		stepUp
   585 	</para>
   586 	</listitem>
   587 	<listitem>
   588 	<para>
   589 		msTrustListSign
   590 	</para>
   591 	</listitem>
   592 	<listitem>
   593 	<para>
   594 		critical
   595 	</para>
   596 	</listitem>
   597 	</itemizedlist>
   598 <para>X.509 certificate extensions are described in RFC 5280.</para></listitem>
   599       </varlistentry>
   601       <varlistentry>
   602         <term>-7 emailAddrs</term>
   603         <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>
   604       </varlistentry>
   606       <varlistentry>
   607         <term>-8 dns-names</term>
   608         <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>
   609       </varlistentry>
   611       <varlistentry>
   612         <term>--extAIA</term>
   613         <listitem><para>Add the Authority Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   614       </varlistentry>
   616       <varlistentry>
   617         <term>--extSIA</term>
   618         <listitem><para>Add the Subject Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   619       </varlistentry>
   621       <varlistentry>
   622         <term>--extCP</term>
   623         <listitem><para>Add the Certificate Policies extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   624       </varlistentry>
   626       <varlistentry>
   627         <term>--extPM</term>
   628         <listitem><para>Add the Policy Mappings extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   629       </varlistentry>
   631       <varlistentry>
   632         <term>--extPC</term>
   633         <listitem><para>Add the Policy Constraints extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   634       </varlistentry>
   636       <varlistentry>
   637         <term>--extIA</term>
   638         <listitem><para>Add the Inhibit Any Policy Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   639       </varlistentry>
   641       <varlistentry>
   642         <term>--extSKID</term>
   643         <listitem><para>Add the Subject Key ID extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   644       </varlistentry>
   646       <varlistentry>
   647         <term>--extNC</term>
   648         <listitem><para>Add a Name Constraint extension to the certificate. X.509 certificate extensions are described in RFC 5280.</para></listitem>
   649       </varlistentry>
   651       <varlistentry>
   652         <term>--empty-password</term>
   653         <listitem><para>Use empty password when creating new certificate database with -N.</para></listitem>
   654       </varlistentry>
   656       <varlistentry>
   657         <term>--keyAttrFlags attrflags</term>
   658         <listitem><para>
   659 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>
   660       </varlistentry>
   662       <varlistentry>
   663         <term>--keyOpFlagsOn opflags</term>
   664         <term>--keyOpFlagsOff opflags</term>
   665         <listitem><para>
   666 PKCS #11 key Operation Flags.
   667 Comma separated list of one or more of the following:
   668 {token | session} {public | private} {sensitive | insensitive} {modifiable | unmodifiable} {extractable | unextractable}
   669           </para></listitem>
   670       </varlistentry>
   672       <varlistentry>
   673         <term>--source-dir certdir</term>
   674         <listitem><para>Identify the certificate database directory to upgrade.</para></listitem>
   675       </varlistentry>
   677       <varlistentry>
   678         <term>--source-prefix certdir</term>
   679         <listitem><para>Give the prefix of the certificate and key databases to upgrade.</para></listitem>
   680       </varlistentry>
   682       <varlistentry>
   683         <term>--upgrade-id uniqueID</term>
   684         <listitem><para>Give the unique ID of the database to upgrade.</para></listitem>
   685       </varlistentry>
   687       <varlistentry>
   688         <term>--upgrade-token-name name</term>
   689         <listitem><para>Set the name of the token to use while it is being upgraded.</para></listitem>
   690       </varlistentry>
   692       <varlistentry>
   693         <term>-@ pwfile</term>
   694         <listitem><para>Give the name of a password file to use for the database being upgraded.</para></listitem>
   695       </varlistentry>
   697     </variablelist>
   698   </refsection>
   700   <refsection id="basic-usage">
   701     <title>Usage and Examples</title>
   702 	<para>
   703 		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.
   704 	</para>
   705 	<para><command>Creating New Security Databases</command></para>
   706 	<para>
   707 		Certificates, keys, and security modules related to managing certificates are stored in three related databases:
   708 	</para>
   709 	<itemizedlist>
   710 	<listitem>
   711 	<para>
   712 		cert8.db or cert9.db
   713 	</para>
   714 	</listitem>
   715 	<listitem>
   716 	<para>
   717 		key3.db or key4.db
   718 	</para>
   719 	</listitem>
   720 	<listitem>
   721 	<para>
   722 		secmod.db or pkcs11.txt
   723 	</para>
   724 	</listitem>
   725 	</itemizedlist>
   726 	<para>
   727 		These databases must be created before certificates or keys can be generated.
   728 	</para>
   729 <programlisting>certutil -N -d [sql:]directory</programlisting>
   731 	<para><command>Creating a Certificate Request</command></para>
   732 	<para>
   733 		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.
   734 	</para>
   735 <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>
   736 	<para>
   737 		The <option>-R</option> command options requires four arguments:
   738 	</para>
   739 	<itemizedlist>
   740 	<listitem>
   741 	<para>
   742 		<option>-k</option> to specify either the key type to generate or, when renewing a certificate, the existing key pair to use
   743 	</para>
   744 	</listitem>
   745 	<listitem>
   746 	<para>
   747 		<option>-g</option> to set the keysize of the key to generate
   748 	</para>
   749 	</listitem>
   750 	<listitem>
   751 	<para>
   752 		<option>-s</option> to set the subject name of the certificate
   753 	</para>
   754 	</listitem>
   755 	<listitem>
   756 	<para>
   757 		<option>-d</option> to give the security database directory
   758 	</para>
   759 	</listitem>
   760 	</itemizedlist>
   761 	<para>
   762 		The new certificate request can be output in ASCII format (<option>-a</option>) or can be written to a specified file (<option>-o</option>).
   763 	</para>
   764 	<para>
   765 		For example:
   766 	</para>
   767 <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
   769 Generating key.  This may take a few moments...
   771 </programlisting>
   773 	<para><command>Creating a Certificate</command></para>
   774 	<para>
   775 		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.
   776 	</para>
   777 <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>
   778 	<para>
   779 		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.
   780 	</para>
   781 	<para>
   782 		For example, this creates a self-signed certificate:
   783 	</para>
   784 <programlisting>$ certutil -S -s "CN=Example CA" -n my-ca-cert -x -t "C,C,C" -1 -2 -5 -m 3650</programlisting>
   785 	<para>
   786 The interative prompts for key usage and whether any extensions are critical and responses have been ommitted for brevity.
   787 	</para>
   788 	<para>
   789 		From there, new certificates can reference the self-signed certificate:
   790 	</para>
   791 <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>
   793 	<para><command>Generating a Certificate from a Certificate Request</command></para>
   794 	<para>
   795 		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.
   796 	</para>
   797 <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>
   798 	<para>
   799 		For example:
   800 	</para>
   801 <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>
   803 	<para><command>Listing Certificates</command></para>
   804 	<para>
   805 		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.
   806 	</para>
   807 <programlisting>$ certutil -L -d sql:/home/my/sharednssdb
   809 Certificate Nickname                                         Trust Attributes
   810                                                              SSL,S/MIME,JAR/XPI
   812 CA Administrator of Instance pki-ca1's Example Domain ID     u,u,u
   813 TPS Administrator's Example Domain ID                        u,u,u
   814 Google Internet Authority                                    ,,   
   815 Certificate Authority - Example Domain                       CT,C,C</programlisting>
   816 	<para>
   817 		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:
   818 	</para>
   819 <programlisting>
   820 $ certutil -L -d sql:$HOME/nssdb -a -n my-ca-cert
   821 -----BEGIN CERTIFICATE-----
   822 MIIB1DCCAT2gAwIBAgICDkIwDQYJKoZIhvcNAQEFBQAwFTETMBEGA1UEAxMKRXhh
   823 bXBsZSBDQTAeFw0xMzAzMTMxOTEwMjlaFw0xMzA2MTMxOTEwMjlaMBUxEzARBgNV
   824 BAMTCkV4YW1wbGUgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJ4Kzqvz
   825 JyBVgFqDXRYSyTBNw1DrxUU/3GvWA/ngjAwHEv0Cul/6sO/gsCvnABHiH6unns6x
   826 XRzPORlC2WY3gkk7vmlsLvYpyecNazAi/NAwVnU/66HOsaoVFWE+gBQo99UrN2yk
   827 0BiK/GMFlLm5dXQROgA9ZKKyFdI0LIXtf6SbAgMBAAGjMzAxMBEGCWCGSAGG+EIB
   828 AQQEAwIHADAMBgNVHRMEBTADAQH/MA4GA1UdDwEB/wQEAwICBDANBgkqhkiG9w0B
   829 AQUFAAOBgQA6chkzkACN281d1jKMrc+RHG2UMaQyxiteaLVZO+Ro1nnRUvseDf09
   830 XKYFwPMJjWCihVku6bw/ihZfuMHhxK22Nue6inNQ6eDu7WmrqL8z3iUrQwxs+WiF
   831 ob2rb8XRVVJkzXdXxlk4uo3UtNvw8sAz7sWD71qxKaIHU5q49zijfg==
   832 -----END CERTIFICATE-----
   833 </programlisting>
   834 <para>For a human-readable display</para>
   835 <programlisting>$ certutil -L -d sql:$HOME/nssdb -n my-ca-cert
   836 Certificate:
   837     Data:
   838         Version: 3 (0x2)
   839         Serial Number: 3650 (0xe42)
   840         Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
   841         Issuer: "CN=Example CA"
   842         Validity:
   843             Not Before: Wed Mar 13 19:10:29 2013
   844             Not After : Thu Jun 13 19:10:29 2013
   845         Subject: "CN=Example CA"
   846         Subject Public Key Info:
   847             Public Key Algorithm: PKCS #1 RSA Encryption
   848             RSA Public Key:
   849                 Modulus:
   850                     9e:0a:ce:ab:f3:27:20:55:80:5a:83:5d:16:12:c9:30:
   851                     4d:c3:50:eb:c5:45:3f:dc:6b:d6:03:f9:e0:8c:0c:07:
   852                     12:fd:02:ba:5f:fa:b0:ef:e0:b0:2b:e7:00:11:e2:1f:
   853                     ab:a7:9e:ce:b1:5d:1c:cf:39:19:42:d9:66:37:82:49:
   854                     3b:be:69:6c:2e:f6:29:c9:e7:0d:6b:30:22:fc:d0:30:
   855                     56:75:3f:eb:a1:ce:b1:aa:15:15:61:3e:80:14:28:f7:
   856                     d5:2b:37:6c:a4:d0:18:8a:fc:63:05:94:b9:b9:75:74:
   857                     11:3a:00:3d:64:a2:b2:15:d2:34:2c:85:ed:7f:a4:9b
   858                 Exponent: 65537 (0x10001)
   859         Signed Extensions:
   860             Name: Certificate Type
   861             Data: none
   863             Name: Certificate Basic Constraints
   864             Data: Is a CA with no maximum path length.
   866             Name: Certificate Key Usage
   867             Critical: True
   868             Usages: Certificate Signing
   870     Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
   871     Signature:
   872         3a:72:19:33:90:00:8d:db:cd:5d:d6:32:8c:ad:cf:91:
   873         1c:6d:94:31:a4:32:c6:2b:5e:68:b5:59:3b:e4:68:d6:
   874         79:d1:52:fb:1e:0d:fd:3d:5c:a6:05:c0:f3:09:8d:60:
   875         a2:85:59:2e:e9:bc:3f:8a:16:5f:b8:c1:e1:c4:ad:b6:
   876         36:e7:ba:8a:73:50:e9:e0:ee:ed:69:ab:a8:bf:33:de:
   877         25:2b:43:0c:6c:f9:68:85:a1:bd:ab:6f:c5:d1:55:52:
   878         64:cd:77:57:c6:59:38:ba:8d:d4:b4:db:f0:f2:c0:33:
   879         ee:c5:83:ef:5a:b1:29:a2:07:53:9a:b8:f7:38:a3:7e
   880     Fingerprint (MD5):
   881         86:D8:A5:8B:8A:26:BE:9E:17:A8:7B:66:10:6B:27:80
   882     Fingerprint (SHA1):
   883         48:78:09:EF:C5:D4:0C:BD:D2:64:45:59:EB:03:13:15:F7:A9:D6:F7
   885     Certificate Trust Flags:
   886         SSL Flags:
   887             Valid CA
   888             Trusted CA
   889             User
   890         Email Flags:
   891             Valid CA
   892             Trusted CA
   893             User
   894         Object Signing Flags:
   895             Valid CA
   896             Trusted CA
   897             User
   899 </programlisting>
   901 	<para><command>Listing Keys</command></para>
   902 	<para>
   903 		Keys are the original material used to encrypt certificate data. The keys generated for certificates are stored separately, in the key database. 
   904 	</para>
   905 	<para>
   906 		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.
   907 	</para>
   908 <programlisting>$ certutil -K -d sql:$HOME/nssdb
   909 certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services                  "
   910 &lt; 0> rsa      455a6673bde9375c2887ec8bf8016b3f9f35861d   Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID
   911 &lt; 1> rsa      40defeeb522ade11090eacebaaf1196a172127df   Example Domain Administrator Cert
   912 &lt; 2> rsa      1d0b06f44f6c03842f7d4f4a1dc78b3bcd1b85a5   John Smith user cert</programlisting>
   913 	<para>
   914 		There are ways to narrow the keys listed in the search results:
   915 	</para>
   916 	<itemizedlist>
   917 	<listitem>
   918 	<para>
   919 		To return a specific key, use the <option>-n</option> <emphasis>name</emphasis> argument with the name of the key.
   920 	</para>
   921 	</listitem>
   922 	<listitem>
   923 	<para>
   924 		If there are multiple security devices loaded, then the <option>-h</option> <emphasis>tokenname</emphasis> argument can search a specific token or all tokens.
   925 	</para>
   926 	</listitem>
   927 	<listitem>
   928 	<para>
   929 		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. 
   930 	</para>
   931 	</listitem>
   932 	</itemizedlist>
   934 	<para><command>Listing Security Modules</command></para>
   935 	<para>
   936 		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.
   937 	</para>
   938 <programlisting>$ certutil -U -d sql:/home/my/sharednssdb
   940     slot: NSS User Private Key and Certificate Services                  
   941    token: NSS Certificate DB
   943     slot: NSS Internal Cryptographic Services                            
   944    token: NSS Generic Crypto Services</programlisting>
   946 	<para><command>Adding Certificates to the Database</command></para>
   947 	<para>
   948 		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.
   949 	</para>
   950 <programlisting>certutil -A -n certname -t trustargs -d [sql:]directory [-a] [-i input-file]</programlisting>
   951 	<para>
   952 		For example:
   953 	</para>
   954 <programlisting>$ certutil -A -n "CN=My SSL Certificate" -t "u,u,u" -d sql:/home/my/sharednssdb -i /home/example-certs/cert.cer</programlisting>
   955 	<para>
   956 		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:
   957 	</para>
   958 <programlisting>$ certutil -E -n "CN=John Smith Email Cert" -t ",Pu," -d sql:/home/my/sharednssdb -i /home/example-certs/email.cer</programlisting>
   960 	<para><command>Deleting Certificates to the Database</command></para>
   961 	<para>
   962 		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.
   963 	</para>
   964 <programlisting>certutil -D -d [sql:]directory -n "nickname"</programlisting>
   965 	<para>
   966 		For example:
   967 	</para>
   968 <programlisting>$ certutil -D -d sql:/home/my/sharednssdb -n "my-ssl-cert"</programlisting>
   970 	<para><command>Validating Certificates</command></para>
   971 	<para>
   972 		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.
   973 	</para>
   974 <programlisting>certutil -V -n certificate-name [-b time] [-e] [-u cert-usage] -d [sql:]directory</programlisting>
   975 	<para>
   976 		For example, to validate an email certificate:
   977 	</para>
   978 <programlisting>$ certutil -V -n "John Smith's Email Cert" -e -u S,R -d sql:/home/my/sharednssdb</programlisting>
   980 	<para><command>Modifying Certificate Trust Settings</command></para>
   981 	<para>
   982 		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.
   983 	</para>
   984 <programlisting>certutil -M -n certificate-name -t trust-args -d [sql:]directory</programlisting>
   985 	<para>
   986 		For example:
   987 	</para>
   988 <programlisting>$ certutil -M -n "My CA Certificate" -d sql:/home/my/sharednssdb -t "CTu,CTu,CTu"</programlisting>
   990 	<para><command>Printing the Certificate Chain</command></para>
   991 	<para>
   992 		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:
   993 	</para>
   994 <programlisting>$ certutil -d sql:/home/my/sharednssdb -O -n "jsmith@example.com"
   995 "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]
   997   "Thawte Personal Freemail Issuing CA - Thawte Consulting" [CN=Thawte Personal Freemail Issuing CA,O=Thawte Consulting (Pty) Ltd.,C=ZA]
   999     "(null)" [E=jsmith@example.com,CN=Thawte Freemail Member]</programlisting>
  1001 	<para><command>Resetting a Token</command></para>
  1002 	<para>
  1003 		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.
  1004 	</para>
  1005 <programlisting>certutil -T -d [sql:]directory -h token-name -0 security-officer-password</programlisting>
  1006 	<para>
  1007 		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:
  1008 	</para>
  1009 <programlisting>$ certutil -T -d sql:/home/my/sharednssdb -h nethsm -0 secret</programlisting>
  1011 	<para><command>Upgrading or Merging the Security Databases</command></para>
  1012 	<para>
  1013 		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.
  1014 	</para>
  1015 	<para>
  1016 		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.
  1017 	</para>
  1018 <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>
  1019 	<para>
  1020 		For example:
  1021 	</para>
  1022 <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>
  1023 	<para>
  1024 		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.
  1025 	</para>
  1026 <programlisting>certutil --merge -d [sql:]directory [-P dbprefix] --source-dir directory --source-prefix dbprefix [-@ password-file]</programlisting>
  1027 	<para>
  1028 		For example:
  1029 	</para>
  1030 <programlisting>$ certutil --merge -d sql:/home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix serverapp-</programlisting>
  1032 	<para><command>Running certutil Commands from a Batch File</command></para>
  1033 	<para>
  1034 		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.
  1035 	</para>
  1036 <programlisting>$ certutil -B -i /path/to/batch-file</programlisting>
  1037   </refsection>
  1039 <refsection id="databases"><title>NSS Database Types</title>
  1040 <para>NSS originally used BerkeleyDB databases to store security information. 
  1041 The last versions of these <emphasis>legacy</emphasis> databases are:</para>
  1042 <itemizedlist>
  1043 	<listitem>
  1044 		<para>
  1045 			cert8.db for certificates
  1046 		</para>
  1047 	</listitem>
  1048 	<listitem>
  1049 		<para>
  1050 			key3.db for keys
  1051 		</para>
  1052 	</listitem>
  1053 	<listitem>
  1054 		<para>
  1055 			secmod.db for PKCS #11 module information
  1056 		</para>
  1057 	</listitem>
  1058 </itemizedlist>
  1060 <para>BerkeleyDB has performance limitations, though, which prevent it from being easily used by multiple applications simultaneously. NSS has 
  1061 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
  1062 requires more flexibility to provide a truly shared security database.</para>
  1064 <para>In 2009, NSS introduced a new set of databases that are SQLite databases rather than 
  1065 BerkeleyDB. These new databases provide more accessibility and performance:</para>
  1066 <itemizedlist>
  1067 	<listitem>
  1068 		<para>
  1069 			cert9.db for certificates
  1070 		</para>
  1071 	</listitem>
  1072 	<listitem>
  1073 		<para>
  1074 			key4.db for keys
  1075 		</para>
  1076 	</listitem>
  1077 	<listitem>
  1078 		<para>
  1079 			pkcs11.txt, a listing of all of the PKCS #11 modules, contained in a new subdirectory in the security databases directory
  1080 		</para>
  1081 	</listitem>
  1082 </itemizedlist>
  1084 <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>
  1086 <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. 
  1087 Using the SQLite databases must be manually specified by using the <command>sql:</command> prefix with the given security directory. For example:</para>
  1089 <programlisting>$ certutil -L -d sql:/home/my/sharednssdb</programlisting>
  1091 <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>
  1092 <programlisting>export NSS_DEFAULT_DB_TYPE="sql"</programlisting>
  1094 <para>This line can be set added to the <filename>~/.bashrc</filename> file to make the change permanent.</para>
  1096 <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>
  1097 <itemizedlist>
  1098 	<listitem>
  1099 		<para>
  1100 			https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
  1101 	</listitem>
  1102 </itemizedlist>
  1103 <para>For an engineering draft on the changes in the shared NSS databases, see the NSS project wiki:</para>
  1104 <itemizedlist>
  1105 	<listitem>
  1106 		<para>
  1107 			https://wiki.mozilla.org/NSS_Shared_DB
  1108 		</para>
  1109 	</listitem>
  1110 </itemizedlist>
  1111 </refsection>
  1114   <refsection id="seealso">
  1115     <title>See Also</title>
  1116     <para>pk12util (1)</para>
  1117     <para>modutil (1)</para>
  1118     <para><command>certutil</command> has arguments or operations that use features defined in several IETF RFCs.</para>
  1119 	<itemizedlist>
  1120 	<listitem>
  1121 	<para>
  1122 		http://tools.ietf.org/html/rfc5280
  1123 	</para>
  1124 	</listitem>
  1125 	<listitem>
  1126 	<para>
  1127 		http://tools.ietf.org/html/rfc1113
  1128 	</para>
  1129 	</listitem>
  1130 	<listitem>
  1131 	<para>
  1132 		http://tools.ietf.org/html/rfc1485
  1133 	</para>
  1134 	</listitem>
  1135 	</itemizedlist>
  1137 	<para>The NSS wiki has information on the new database design and how to configure applications to use it.</para>
  1138         <itemizedlist>
  1139 	<listitem>
  1140 		<para>
  1141 			https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
  1142 	</listitem>
  1143 	<listitem>
  1144 		<para>
  1145 			https://wiki.mozilla.org/NSS_Shared_DB
  1146 		</para>
  1147 	</listitem>
  1148         </itemizedlist>
  1149   </refsection>
  1151 <!-- don't change -->
  1152   <refsection id="resources">
  1153     <title>Additional Resources</title>
  1154 	<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>
  1155 	<para>Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto</para>
  1156 	<para>IRC: Freenode at #dogtag-pki</para>
  1157   </refsection>
  1159 <!-- fill in your name first; keep the other names for reference -->
  1160   <refsection id="authors">
  1161     <title>Authors</title>
  1162     <para>The NSS tools were written and maintained by developers with Netscape, Red Hat,  Sun, Oracle, Mozilla, and Google.</para>
  1163     <para>
  1164 	Authors: Elio Maldonado &lt;emaldona@redhat.com>, Deon Lackey &lt;dlackey@redhat.com>.
  1165     </para>
  1166   </refsection>
  1168 <!-- don't change -->
  1169   <refsection id="license">
  1170     <title>LICENSE</title>
  1171     <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/.
  1172     </para>
  1173   </refsection>
  1175 </refentry>

mercurial