tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

certutil.xml (57309B)


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