tor-browser

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

index.rst (41395B)


      1 .. _mozilla_projects_nss_tools_certutil:
      2 
      3 certutil
      4 ========
      5 
      6 .. container::
      7 
      8   | Name
      9   |    certutil — Manage keys and certificate in the NSS database.
     10   | Synopsis
     11   |    certutil [options] `arguments <arguments>`__
     12   | Description
     13   |    The Certificate Database Tool, certutil, is a command-line utility that
     14   |    can create and modify certificate and key database files. It can also
     15   |    list, generate, modify, or delete certificates within the database, create
     16   |    or change the password, generate new public and private key pairs, display
     17   |    the contents of the key database, or delete key pairs within the key
     18   |    database.
     19   |    The key and certificate management process generally begins with creating
     20   |    keys in the key database, then generating and managing certificates in the
     21   |    certificate database. This document discusses certificate and key database
     22   |    management. For information security module database management, see the
     23   |    modutil manpages.
     24   | Options and Arguments
     25   |    Running certutil always requires one (and only one) option to specify the
     26   |    type of certificate operation. Each option may take arguments, anywhere
     27   |    from none to multiple arguments. Run the command option and -H to see the
     28   |    arguments available for each command option.
     29   |    Options
     30   |    Options specify an action and are uppercase.
     31   |    -A
     32   |            Add an existing certificate to a certificate database. The
     33   |            certificate database should already exist; if one is not present,
     34   |            this option will initialize one by default.
     35   |    -B
     36   |            Run a series of commands from the specified batch file. This
     37   |            requires the -i argument.
     38   |    -C
     39   |            Create a new binary certificate file from a binary certificate
     40   |            request file. Use the -i argument to specify the certificate
     41   |            request file. If this argument is not used, certutil prompts for a
     42   |            filename.
     43   |    -D
     44   |            Delete a certificate from the certificate database.
     45   |    -E
     46   |            Add an email certificate to the certificate database.
     47   |    -F
     48   |            Delete a private key from a key database. Specify the key to
     49   |            delete with the -n argument. Specify the database from which to
     50   |            delete the key with the -d argument. Use the -k argument to
     51   |            specify explicitly whether to delete a DSA, RSA, or ECC key. If
     52   |            you don't use the -k argument, the option looks for an RSA key
     53   |            matching the specified nickname.
     54   |            When you delete keys, be sure to also remove any certificates
     55   |            associated with those keys from the certificate database, by using
     56   |            -D. Some smart cards (for example, the Litronic card) do not let
     57   |            you remove a public key you have generated. In such a case, only
     58   |            the private key is deleted from the key pair. You can display the
     59   |            public key with the command certutil -K -h tokenname.
     60   |    -G
     61   |            Generate a new public and private key pair within a key database.
     62   |            The key database should already exist; if one is not present, this
     63   |            option will initialize one by default. Some smart cards (for
     64   |            example, the Litronic card) can store only one key pair. If you
     65   |            create a new key pair for such a card, the previous pair is
     66   |            overwritten.
     67   |    -H
     68   |            Display a list of the options and arguments used by the
     69   |            Certificate Database Tool.
     70   |    -K
     71   |            List the key ID of keys in the key database. A key ID is the
     72   |            modulus of the RSA key or the publicValue of the DSA key. IDs are
     73   |            displayed in hexadecimal ("0x" is not shown).
     74   |    -L
     75   |            List all the certificates, or display information about a named
     76   |            certificate, in a certificate database. Use the -h tokenname
     77   |            argument to specify the certificate database on a particular
     78   |            hardware or software token.
     79   |    -M
     80   |            Modify a certificate's trust attributes using the values of the -t
     81   |            argument.
     82   |    -N
     83   |            Create new certificate and key databases.
     84   |    -O
     85   |            Print the certificate chain.
     86   |    -R
     87   |            Create a certificate request file that can be submitted to a
     88   |            Certificate Authority (CA) for processing into a finished
     89   |            certificate. Output defaults to standard out unless you use -o
     90   |            output-file argument. Use the -a argument to specify ASCII output.
     91   |    -S
     92   |            Create an individual certificate and add it to a certificate
     93   |            database.
     94   |    -T
     95   |            Reset the key database or token.
     96   |    -U
     97   |            List all available modules or print a single named module.
     98   |    -V
     99   |            Check the validity of a certificate and its attributes.
    100   |    -W
    101   |            Change the password to a key database.
    102   |    --merge
    103   |            Merge a source database into the target database. This is used to
    104   |            merge legacy NSS databases (cert8.db and key3.db) into the newer
    105   |            SQLite databases (cert9.db and key4.db).
    106   |    --upgrade-merge
    107   |            Upgrade an old database and merge it into a new database. This is
    108   |            used to migrate legacy NSS databases (cert8.db and key3.db) into
    109   |            the newer SQLite databases (cert9.db and key4.db).
    110   |    Arguments
    111   |    Option arguments modify an action and are lowercase.
    112   |    -a
    113   |            Use ASCII format or allow the use of ASCII format for input or
    114   |            output. This formatting follows RFC 1113. For certificate
    115   |            requests, ASCII output defaults to standard output unless
    116   |            redirected.
    117   |    -b validity-time
    118   |            Specify a time at which a certificate is required to be valid. Use
    119   |            when checking certificate validity with the -V option. The format
    120   |            of the validity-time argument is YYMMDDHHMMSS[+HHMM|-HHMM|Z],
    121   |            which allows offsets to be set relative to the validity end time.
    122   |            Specifying seconds (SS) is optional. When specifying an explicit
    123   |            time, use a Z at the end of the term, YYMMDDHHMMSSZ, to close it.
    124   |            When specifying an offset time, use YYMMDDHHMMSS+HHMM or
    125   |            YYMMDDHHMMSS-HHMM for adding or subtracting time, respectively.
    126   |            If this option is not used, the validity check defaults to the
    127   |            current system time.
    128   |    -c issuer
    129   |            Identify the certificate of the CA from which a new certificate
    130   |            will derive its authenticity. Use the exact nickname or alias of
    131   |            the CA certificate, or use the CA's email address. Bracket the
    132   |            issuer string with quotation marks if it contains spaces.
    133   |    -d [sql:]directory
    134   |            Specify the database directory containing the certificate and key
    135   |            database files.
    136   |            certutil supports two types of databases: the legacy security
    137   |            databases (cert8.db, key3.db, and secmod.db) and new SQLite
    138   |            databases (cert9.db, key4.db, and pkcs11.txt). If the prefix sql:
    139   |            is not used, then the tool assumes that the given databases are in
    140   |            the old format.
    141   |    -e
    142   |            Check a certificate's signature during the process of validating a
    143   |            certificate.
    144   |    -f password-file
    145   |            Specify a file that will automatically supply the password to
    146   |            include in a certificate or to access a certificate database. This
    147   |            is a plain-text file containing one password. Be sure to prevent
    148   |            unauthorized access to this file.
    149   |    -g keysize
    150   |            Set a key size to use when generating new public and private key
    151   |            pairs. The minimum is 512 bits and the maximum is 8192 bits. The
    152   |            default is 1024 bits. Any size between the minimum and maximum is
    153   |            allowed.
    154   |    -h tokenname
    155   |            Specify the name of a token to use or act on. Unless specified
    156   |            otherwise the default token is an internal slot (specifically,
    157   |            internal slot 2). This slot can also be explicitly named with the
    158   |            string "internal". An internal slots is a virtual slot maintained
    159   |            in software, rather than a hardware device. Internal slot 2 is
    160   |            used by key and certificate services. Internal slot 1 is used by
    161   |            cryptographic services.
    162   |    -i input_file
    163   |            Pass an input file to the command. Depending on the command
    164   |            option, an input file can be a specific certificate, a certificate
    165   |            request file, or a batch file of commands.
    166   |    -k rsa|dsa|ec|all
    167   |            Specify the type of a key. The valid options are RSA, DSA, ECC, or
    168   |            all. The default value is rsa. Specifying the type of key can
    169   |            avoid mistakes caused by duplicate nicknames.
    170   |    -k key-type-or-id
    171   |            Specify the type or specific ID of a key. Giving a key type
    172   |            generates a new key pair; giving the ID of an existing key reuses
    173   |            that key pair (which is required to renew certificates).
    174   |    -l
    175   |            Display detailed information when validating a certificate with
    176   |            the -V option.
    177   |    -m serial-number
    178   |            Assign a unique serial number to a certificate being created. This
    179   |            operation should be performed by a CA. The default serial number
    180   |            is 0 (zero). Serial numbers are limited to integers.
    181   |    -n nickname
    182   |            Specify the nickname of a certificate or key to list, create, add
    183   |            to a database, modify, or validate. Bracket the nickname string
    184   |            with quotation marks if it contains spaces.
    185   |    -o output-file
    186   |            Specify the output file name for new certificates or binary
    187   |            certificate requests. Bracket the output-file string with
    188   |            quotation marks if it contains spaces. If this argument is not
    189   |            used the output destination defaults to standard output.
    190   |    -P dbPrefix
    191   |            Specify the prefix used on the certificate and key database file.
    192   |            This option is provided as a special case. Changing the names of
    193   |            the certificate and key databases is not recommended.
    194   |    -p phone
    195   |            Specify a contact telephone number to include in new certificates
    196   |            or certificate requests. Bracket this string with quotation marks
    197   |            if it contains spaces.
    198   |    -q pqgfile
    199   |            Read an alternate PQG value from the specified file when
    200   |            generating DSA key pairs. If this argument is not used, certutil
    201   |            generates its own PQG value. PQG files are created with a separate
    202   |            DSA utility.
    203   |    -q curve-name
    204   |            Set the elliptic curve name to use when generating ECC key pairs.
    205   |            A complete list of ECC curves is given in the help (-H).
    206   |    -r
    207   |            Display a certificate's binary DER encoding when listing
    208   |            information about that certificate with the -L option.
    209   |    -s subject
    210   |            Identify a particular certificate owner for new certificates or
    211   |            certificate requests. Bracket this string with quotation marks if
    212   |            it contains spaces. The subject identification format follows RFC
    213   |            #1485.
    214   |    -t trustargs
    215   |            Specify the trust attributes to modify in an existing certificate
    216   |            or to apply to a certificate when creating it or adding it to a
    217   |            database. There are three available trust categories for each
    218   |            certificate, expressed in the order SSL, email, object signing for
    219   |            each trust setting. In each category position, use none, any, or
    220   |            all of the attribute codes:
    221   |               o p - Valid peer
    222   |               o P - Trusted peer (implies p)
    223   |               o c - Valid CA
    224   |               o T - Trusted CA to issue client certificates (implies c)
    225   |               o C - Trusted CA to issue server certificates (SSL only)
    226   |                 (implies c)
    227   |               o u - Certificate can be used for authentication or signing
    228   |               o w - Send warning (use with other attributes to include a
    229   |                 warning when the certificate is used in that context)
    230   |            The attribute codes for the categories are separated by commas,
    231   |            and the entire set of attributes enclosed by quotation marks. For
    232   |            example:
    233   |            -t "TCu,Cu,Tuw"
    234   |            Use the -L option to see a list of the current certificates and
    235   |            trust attributes in a certificate database.
    236   |    -u certusage
    237   |            Specify a usage context to apply when validating a certificate
    238   |            with the -V option.
    239   |            The contexts are the following:
    240   |               o C (as an SSL client)
    241   |               o V (as an SSL server)
    242   |               o S (as an email signer)
    243   |               o R (as an email recipient)
    244   |               o O (as an OCSP status responder)
    245   |               o J (as an object signer)
    246   |    -v valid-months
    247   |            Set the number of months a new certificate will be valid. The
    248   |            validity period begins at the current system time unless an offset
    249   |            is added or subtracted with the -w option. If this argument is not
    250   |            used, the default validity period is three months. When this
    251   |            argument is used, the default three-month period is automatically
    252   |            added to any value given in the valid-month argument. For example,
    253   |            using this option to set a value of 3 would cause 3 to be added to
    254   |            the three-month default, creating a validity period of six months.
    255   |            You can use negative values to reduce the default period. For
    256   |            example, setting a value of -2 would subtract 2 from the default
    257   |            and create a validity period of one month.
    258   |    -w offset-months
    259   |            Set an offset from the current system time, in months, for the
    260   |            beginning of a certificate's validity period. Use when creating
    261   |            the certificate or adding it to a database. Express the offset in
    262   |            integers, using a minus sign (-) to indicate a negative offset. If
    263   |            this argument is not used, the validity period begins at the
    264   |            current system time. The length of the validity period is set with
    265   |            the -v argument.
    266   |    -X
    267   |            Force the key and certificate database to open in read-write mode.
    268   |            This is used with the -U and -L command options.
    269   |    -x
    270   |            Use certutil to generate the signature for a certificate being
    271   |            created or added to a database, rather than obtaining a signature
    272   |            from a separate CA.
    273   |    -y exp
    274   |            Set an alternate exponent value to use in generating a new RSA
    275   |            public key for the database, instead of the default value of
    276   |            65537. The available alternate values are 3 and 17.
    277   |    -z noise-file
    278   |            Read a seed value from the specified file to generate a new
    279   |            private and public key pair. This argument makes it possible to
    280   |            use hardware-generated seed values or manually create a value from
    281   |            the keyboard. The minimum file size is 20 bytes.
    282   |    -0 SSO_password
    283   |            Set a site security officer password on a token.
    284   |    -1 \| --keyUsage keyword,keyword
    285   |            Set a Netscape Certificate Type Extension in the certificate.
    286   |            There are several available keywords:
    287   |               o digital signature
    288   |               o nonRepudiation
    289   |               o keyEncipherment
    290   |               o dataEncipherment
    291   |               o keyAgreement
    292   |               o certSigning
    293   |               o crlSigning
    294   |               o critical
    295   |    -2
    296   |            Add a basic constraint extension to a certificate that is being
    297   |            created or added to a database. This extension supports the
    298   |            certificate chain verification process. certutil prompts for the
    299   |            certificate constraint extension to select.
    300   |            X.509 certificate extensions are described in RFC 5280.
    301   |    -3
    302   |            Add an authority key ID extension to a certificate that is being
    303   |            created or added to a database. This extension supports the
    304   |            identification of a particular certificate, from among multiple
    305   |            certificates associated with one subject name, as the correct
    306   |            issuer of a certificate. The Certificate Database Tool will prompt
    307   |            you to select the authority key ID extension.
    308   |            X.509 certificate extensions are described in RFC 5280.
    309   |    -4
    310   |            Add a CRL distribution point extension to a certificate that is
    311   |            being created or added to a database. This extension identifies
    312   |            the URL of a certificate's associated certificate revocation list
    313   |            (CRL). certutil prompts for the URL.
    314   |            X.509 certificate extensions are described in RFC 5280.
    315   |    -5 \| --nsCertType keyword,keyword
    316   |            Add a Netscape certificate type extension to a certificate that is
    317   |            being created or added to the database. There are several
    318   |            available keywords:
    319   |               o sslClient
    320   |               o sslServer
    321   |               o smime
    322   |               o objectSigning
    323   |               o sslCA
    324   |               o smimeCA
    325   |               o objectSigningCA
    326   |               o critical
    327   |            X.509 certificate extensions are described in RFC 5280.
    328   |    -6 \| --extKeyUsage keyword,keyword
    329   |            Add an extended key usage extension to a certificate that is being
    330   |            created or added to the database. Several keywords are available:
    331   |               o serverAuth
    332   |               o clientAuth
    333   |               o codeSigning
    334   |               o emailProtection
    335   |               o timeStamp
    336   |               o ocspResponder
    337   |               o stepUp
    338   |               o critical
    339   |            X.509 certificate extensions are described in RFC 5280.
    340   |    -7 emailAddrs
    341   |            Add a comma-separated list of email addresses to the subject
    342   |            alternative name extension of a certificate or certificate request
    343   |            that is being created or added to the database. Subject
    344   |            alternative name extensions are described in Section 4.2.1.7 of
    345   |            RFC 3280.
    346   |    -8 dns-names
    347   |            Add a comma-separated list of DNS names to the subject alternative
    348   |            name extension of a certificate or certificate request that is
    349   |            being created or added to the database. Subject alternative name
    350   |            extensions are described in Section 4.2.1.7 of RFC 3280.
    351   |    --extAIA
    352   |            Add the Authority Information Access extension to the certificate.
    353   |            X.509 certificate extensions are described in RFC 5280.
    354   |    --extSIA
    355   |            Add the Subject Information Access extension to the certificate.
    356   |            X.509 certificate extensions are described in RFC 5280.
    357   |    --extCP
    358   |            Add the Certificate Policies extension to the certificate. X.509
    359   |            certificate extensions are described in RFC 5280.
    360   |    --extPM
    361   |            Add the Policy Mappings extension to the certificate. X.509
    362   |            certificate extensions are described in RFC 5280.
    363   |    --extPC
    364   |            Add the Policy Constraints extension to the certificate. X.509
    365   |            certificate extensions are described in RFC 5280.
    366   |    --extIA
    367   |            Add the Inhibit Any Policy Access extension to the certificate.
    368   |            X.509 certificate extensions are described in RFC 5280.
    369   |    --extSKID
    370   |            Add the Subject Key ID extension to the certificate. X.509
    371   |            certificate extensions are described in RFC 5280.
    372   |    --source-dir certdir
    373   |            Identify the certificate database directory to upgrade.
    374   |    --source-prefix certdir
    375   |            Give the prefix of the certificate and key databases to upgrade.
    376   |    --upgrade-id uniqueID
    377   |            Give the unique ID of the database to upgrade.
    378   |    --upgrade-token-name name
    379   |            Set the name of the token to use while it is being upgraded.
    380   |    -@ pwfile
    381   |            Give the name of a password file to use for the database being
    382   |            upgraded.
    383   | Usage and Examples
    384   |    Most of the command options in the examples listed here have more
    385   |    arguments available. The arguments included in these examples are the most
    386   |    common ones or are used to illustrate a specific scenario. Use the -H
    387   |    option to show the complete list of arguments for each command option.
    388   |    Creating New Security Databases
    389   |    Certificates, keys, and security modules related to managing certificates
    390   |    are stored in three related databases:
    391   |      o cert8.db or cert9.db
    392   |      o key3.db or key4.db
    393   |      o secmod.db or pkcs11.txt
    394   |    These databases must be created before certificates or keys can be
    395   |    generated.
    396   |  certutil -N -d [sql:]directory
    397   |    Creating a Certificate Request
    398   |    A certificate request contains most or all of the information that is used
    399   |    to generate the final certificate. This request is submitted separately to
    400   |    a certificate authority and is then approved by some mechanism
    401   |    (automatically or by human review). Once the request is approved, then the
    402   |    certificate is generated.
    403   |  $ certutil -R -k key-type-or-id [-q pqgfile|curve-name] -g key-size -s subject [-h tokenname]
    404     -d [sql:]directory [-p phone] [-o output-file] [-a]
    405   |    The -R command options requires four arguments:
    406   |      o -k to specify either the key type to generate or, when renewing a
    407   |        certificate, the existing key pair to use
    408   |      o -g to set the keysize of the key to generate
    409   |      o -s to set the subject name of the certificate
    410   |      o -d to give the security database directory
    411   |    The new certificate request can be output in ASCII format (-a) or can be
    412   |    written to a specified file (-o).
    413   |    For example:
    414   |  $ certutil -R -k ec -q nistb409 -g 512 -s "CN=John Smith,O=Example Corp,L=Mountain
    415     View,ST=California,C=US" -d sql:/home/my/sharednssdb -p 650-555-0123 -a -o cert.cer
    416   |  Generating key.  This may take a few moments...
    417   |  Certificate request generated by Netscape
    418   |  Phone: 650-555-0123
    419   |  Common Name: John Smith
    420   |  Email: (not ed)
    421   |  Organization: Example Corp
    422   |  State: California
    423   |  Country: US
    424   |  -----BEGIN NEW CERTIFICATE REQUEST-----
    425   |  MIIBIDCBywIBADBmMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEW
    426   |  MBQGA1UEBxMNTW91bnRhaW4gVmlldzEVMBMGA1UEChMMRXhhbXBsZSBDb3JwMRMw
    427   |  EQYDVQQDEwpKb2huIFNtaXRoMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMVUpDOZ
    428   |  KmHnOx7reP8Cc0Lk+fFWEuYIDX9W5K/BioQOKvEjXyQZhit9aThzBVMoSf1Y1S8J
    429   |  CzdUbCg1+IbnXaECAwEAAaAAMA0GCSqGSIb3DQEBBQUAA0EAryqZvpYrUtQ486Ny
    430   |  qmtyQNjIi1F8c1Z+TL4uFYlMg8z6LG/J/u1E5t1QqB5e9Q4+BhRbrQjRR1JZx3tB
    431   |  1hP9Gg==
    432   |  -----END NEW CERTIFICATE REQUEST-----
    433   |    Creating a Certificate
    434   |    A valid certificate must be issued by a trusted CA. This can be done by
    435   |    specifying a CA certificate (-c) that is stored in the certificate
    436   |    database. If a CA key pair is not available, you can create a self-signed
    437   |    certificate using the -x argument with the -S command option.
    438   |  $ certutil -S -k rsa|dsa|ec -n certname -s subject [-c issuer \|-x] -t trustargs -d
    439     [sql:]directory [-m serial-number] [-v valid-months] [-w offset-months] [-p phone] [-1] [-2]
    440     [-3] [-4] [-5 keyword] [-6 keyword] [-7 emailAddress] [-8 dns-names] [--extAIA] [--extSIA]
    441     [--extCP] [--extPM] [--extPC] [--extIA] [--extSKID]
    442   |    The series of numbers and --ext\* options set certificate extensions that
    443   |    can be added to the certificate when it is generated by the CA.
    444   |    For example, this creates a self-signed certificate:
    445   |  $ certutil -S -s "CN=Example CA" -n my-ca-cert -x -t "C,C,C" -1 -2 -5 -m 3650
    446   |    From there, new certificates can reference the self-signed certificate:
    447   |  $ certutil -S -s "CN=My Server Cert" -n my-server-cert -c "my-ca-cert" -t "u,u,u" -1 -5 -6 -8
    448     -m 730
    449   |    Generating a Certificate from a Certificate Request
    450   |    When a certificate request is created, a certificate can be generated by
    451   |    using the request and then referencing a certificate authority signing
    452   |    certificate (the issuer specified in the -c argument). The issuing
    453   |    certificate must be in the certificate database in the specified
    454   |    directory.
    455   |  certutil -C -c issuer -i cert-request-file -o output-file [-m serial-number] [-v valid-months]
    456     [-w offset-months] -d [sql:]directory [-1] [-2] [-3] [-4] [-5 keyword] [-6 keyword] [-7
    457     emailAddress] [-8 dns-names]
    458   |    For example:
    459   |  $ certutil -C -c "my-ca-cert" -i /home/certs/cert.req -o cert.cer -m 010 -v 12 -w 1 -d
    460     sql:/home/my/sharednssdb -1 nonRepudiation,dataEncipherment -5 sslClient -6 clientAuth -7
    461     jsmith@example.com
    462   |    Generating Key Pairs
    463   |    Key pairs are generated automatically with a certificate request or
    464   |    certificate, but they can also be generated independently using the -G
    465   |    command option.
    466   |  certutil -G -d [sql:]directory \| -h tokenname -k key-type -g key-size [-y exponent-value] -q
    467     pqgfile|curve-name
    468   |    For example:
    469   |  $ certutil -G -h lunasa -k ec -g 256 -q sect193r2
    470   |    Listing Certificates
    471   |    The -L command option lists all of the certificates listed in the
    472   |    certificate database. The path to the directory (-d) is required.
    473   |  $ certutil -L -d sql:/home/my/sharednssdb
    474   |  Certificate Nickname                                         Trust Attributes
    475   |                                                               SSL,S/MIME,JAR/XPI
    476   |  CA Administrator of Instance pki-ca1's Example Domain ID     u,u,u
    477   |  TPS Administrator's Example Domain ID                        u,u,u
    478   |  Google Internet Authority                                    ,,
    479   |  Certificate Authority - Example Domain                       CT,C,C
    480   |    Using additional arguments with -L can return and print the information
    481   |    for a single, specific certificate. For example, the -n argument passes
    482   |    the certificate name, while the -a argument prints the certificate in
    483   |    ASCII format:
    484   |  $ certutil -L -d sql:/home/my/sharednssdb -a -n "Certificate Authority - Example Domain"
    485   |  -----BEGIN CERTIFICATE-----
    486   |  MIIDmTCCAoGgAwIBAgIBATANBgkqhkiG9w0BAQUFADA5MRcwFQYDVQQKEw5FeGFt
    487   |  cGxlIERvbWFpbjEeMBwGA1UEAxMVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEw
    488   |  MDQyOTIxNTY1OFoXDTEyMDQxODIxNTY1OFowOTEXMBUGA1UEChMORXhhbXBsZSBE
    489   |  b21haW4xHjAcBgNVBAMTFUNlcnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZI
    490   |  hvcNAQEBBQADggEPADCCAQoCggEBAO/bqUli2KwqXFKmMMG93KN1SANzNTXA/Vlf
    491   |  Tmrih3hQgjvR1ktIY9aG6cB7DSKWmtHp/+p4PUCMqL4ZrSGt901qxkePyZ2dYmM2
    492   |  RnelK+SEUIPiUtoZaDhNdiYsE/yuDE8vQWj0vHCVL0w72qFUcSQ/WZT7FCrnUIUI
    493   |  udeWnoPSUn70gLhcj/lvxl7K9BHyD4Sq5CzktwYtFWLiiwV+ZY/Fl6JgbGaQyQB2
    494   |  bP4iRMfloGqsxGuB1evWVDF1haGpFDSPgMnEPSLg3/3dXn+HDJbZ29EU8/xKzQEb
    495   |  3V0AHKbu80zGllLEt2Zx/WDIrgJEN9yMfgKFpcmL+BvIRsmh0VsCAwEAAaOBqzCB
    496   |  qDAfBgNVHSMEGDAWgBQATgxHQyRUfKIZtdp55bZlFr+tFzAPBgNVHRMBAf8EBTAD
    497   |  AQH/MA4GA1UdDwEB/wQEAwIBxjAdBgNVHQ4EFgQUAE4MR0MkVHyiGbXaeeW2ZRa/
    498   |  rRcwRQYIKwYBBQUHAQEEOTA3MDUGCCsGAQUFBzABhilodHRwOi8vbG9jYWxob3N0
    499   |  LmxvY2FsZG9tYWluOjkxODAvY2Evb2NzcDANBgkqhkiG9w0BAQUFAAOCAQEAi8Gk
    500   |  L3XO43u7/TDOeEsWPmq+jZsDZ3GZ85Ajt3KROLWeKVZZZa2E2Hnsvf2uXbk5amKe
    501   |  lRxdSeRH9g85pv4KY7Z8xZ71NrI3+K3uwmnqkc6t0hhYb1mw/gx8OAAoluQx3biX
    502   |  JBDxjI73Cf7XUopplHBjjiwyGIJUO8BEZJ5L+TF4P38MJz1snLtzZpEAX5bl0U76
    503   |  bfu/tZFWBbE8YAWYtkCtMcalBPj6jn2WD3M01kGozW4mmbvsj1cRB9HnsGsqyHCu
    504   |  U0ujlL1H/RWcjn607+CTeKH9jLMUqCIqPJNOa+kq/6F7NhNRRiuzASIbZc30BZ5a
    505   |  nI7q5n1USM3eWQlVXw==
    506   |  -----END CERTIFICATE-----
    507   |    Listing Keys
    508   |    Keys are the original material used to encrypt certificate data. The keys
    509   |    generated for certificates are stored separately, in the key database.
    510   |    To list all keys in the database, use the -K command option and the
    511   |    (required) -d argument to give the path to the directory.
    512   |  $ certutil -K -d sql:/home/my/sharednssdb
    513   |  certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate
    514     Services                  "
    515   |  < 0> rsa      455a6673bde9375c2887ec8bf8016b3f9f35861d   Thawte Freemail Member's Thawte
    516     Consulting (Pty) Ltd. ID
    517   |  < 1> rsa      40defeeb522ade11090eacebaaf1196a172127df   Example Domain Administrator Cert
    518   |  < 2> rsa      1d0b06f44f6c03842f7d4f4a1dc78b3bcd1b85a5   John Smith user cert
    519   |    There are ways to narrow the keys listed in the search results:
    520   |      o To return a specific key, use the -n name argument with the name of
    521   |        the key.
    522   |      o If there are multiple security devices loaded, then the -h tokenname
    523   |        argument can search a specific token or all tokens.
    524   |      o If there are multiple key types available, then the -k key-type
    525   |        argument can search a specific type of key, like RSA, DSA, or ECC.
    526   |    Listing Security Modules
    527   |    The devices that can be used to store certificates -- both internal
    528   |    databases and external devices like smart cards -- are recognized and used
    529   |    by loading security modules. The -U command option lists all of the
    530   |    security modules listed in the secmod.db database. The path to the
    531   |    directory (-d) is required.
    532   |  $ certutil -U -d sql:/home/my/sharednssdb
    533   |      slot: NSS User Private Key and Certificate Services
    534   |     token: NSS Certificate DB
    535   |      slot: NSS Internal Cryptographic Services
    536   |     token: NSS Generic Crypto Services
    537   |    Adding Certificates to the Database
    538   |    Existing certificates or certificate requests can be added manually to the
    539   |    certificate database, even if they were generated elsewhere. This uses the
    540   |    -A command option.
    541   |  certutil -A -n certname -t trustargs -d [sql:]directory [-a] [-i input-file]
    542   |    For example:
    543   |  $ certutil -A -n "CN=My SSL Certificate" -t "u,u,u" -d sql:/home/my/sharednssdb -i
    544     /home/example-certs/cert.cer
    545   |    A related command option, -E, is used specifically to add email
    546   |    certificates to the certificate database. The -E command has the same
    547   |    arguments as the -A command. The trust arguments for certificates have the
    548   |    format SSL,S/MIME,Code-signing, so the middle trust settings relate most
    549   |    to email certificates (though the others can be set). For example:
    550   |  $ certutil -E -n "CN=John Smith Email Cert" -t ",Pu," -d sql:/home/my/sharednssdb -i
    551     /home/example-certs/email.cer
    552   |    Deleting Certificates to the Database
    553   |    Certificates can be deleted from a database using the -D option. The only
    554   |    required options are to give the security database directory and to
    555   |    identify the certificate nickname.
    556   |  certutil -D -d [sql:]directory -n "nickname"
    557   |    For example:
    558   |  $ certutil -D -d sql:/home/my/sharednssdb -n "my-ssl-cert"
    559   |    Validating Certificates
    560   |    A certificate contains an expiration date in itself, and expired
    561   |    certificates are easily rejected. However, certificates can also be
    562   |    revoked before they hit their expiration date. Checking whether a
    563   |    certificate has been revoked requires validating the certificate.
    564   |    Validation can also be used to ensure that the certificate is only used
    565   |    for the purposes it was initially issued for. Validation is carried out by
    566   |    the -V command option.
    567   |  certutil -V -n certificate-name [-b time] [-e] [-u cert-usage] -d [sql:]directory
    568   |    For example, to validate an email certificate:
    569   |  $ certutil -V -n "John Smith's Email Cert" -e -u S,R -d sql:/home/my/sharednssdb
    570   |    Modifying Certificate Trust Settings
    571   |    The trust settings (which relate to the operations that a certificate is
    572   |    allowed to be used for) can be changed after a certificate is created or
    573   |    added to the database. This is especially useful for CA certificates, but
    574   |    it can be performed for any type of certificate.
    575   |  certutil -M -n certificate-name -t trust-args -d [sql:]directory
    576   |    For example:
    577   |  $ certutil -M -n "My CA Certificate" -d sql:/home/my/sharednssdb -t "CTu,CTu,CTu"
    578   |    Printing the Certificate Chain
    579   |    Certificates can be issued in chains because every certificate authority
    580   |    itself has a certificate; when a CA issues a certificate, it essentially
    581   |    stamps that certificate with its own fingerprint. The -O prints the full
    582   |    chain of a certificate, going from the initial CA (the root CA) through
    583   |    ever intermediary CA to the actual certificate. For example, for an email
    584   |    certificate with two CAs in the chain:
    585   |  $ certutil -d sql:/home/my/sharednssdb -O -n "jsmith@example.com"
    586   |  "Builtin Object Token:Thawte Personal Freemail CA" [E=personal-freemail@thawte.com,CN=Thawte
    587     Personal Freemail CA,OU=Certification Services Division,O=Thawte Consulting,L=Cape
    588     Town,ST=Western Cape,C=ZA]
    589   |    "Thawte Personal Freemail Issuing CA - Thawte Consulting" [CN=Thawte Personal Freemail
    590     Issuing CA,O=Thawte Consulting (Pty) Ltd.,C=ZA]
    591   |      "(null)" [E=jsmith@example.com,CN=Thawte Freemail Member]
    592   |    Resetting a Token
    593   |    The device which stores certificates -- both external hardware devices and
    594   |    internal software databases -- can be blanked and reused. This operation
    595   |    is performed on the device which stores the data, not directly on the
    596   |    security databases, so the location must be referenced through the token
    597   |    name (-h) as well as any directory path. If there is no external token
    598   |    used, the default value is internal.
    599   |  certutil -T -d [sql:]directory -h token-name -0 security-officer-password
    600   |    Many networks have dedicated personnel who handle changes to security
    601   |    tokens (the security officer). This person must supply the password to
    602   |    access the specified token. For example:
    603   |  $ certutil -T -d sql:/home/my/sharednssdb -h nethsm -0 secret
    604   |    Upgrading or Merging the Security Databases
    605   |    Many networks or applications may be using older BerkeleyDB versions of
    606   |    the certificate database (cert8.db). Databases can be upgraded to the new
    607   |    SQLite version of the database (cert9.db) using the --upgrade-merge
    608   |    command option or existing databases can be merged with the new cert9.db
    609   |    databases using the ---merge command.
    610   |    The --upgrade-merge command must give information about the original
    611   |    database and then use the standard arguments (like -d) to give the
    612   |    information about the new databases. The command also requires information
    613   |    that the tool uses for the process to upgrade and write over the original
    614   |    database.
    615   |  certutil --upgrade-merge -d [sql:]directory [-P dbprefix] --source-dir directory
    616     --source-prefix dbprefix --upgrade-id id --upgrade-token-name name [-@ password-file]
    617   |    For example:
    618   |  $ certutil --upgrade-merge -d sql:/home/my/sharednssdb --source-dir /opt/my-app/alias/
    619     --source-prefix serverapp- --upgrade-id 1 --upgrade-token-name internal
    620   |    The --merge command only requires information about the location of the
    621   |    original database; since it doesn't change the format of the database, it
    622   |    can write over information without performing interim step.
    623   |  certutil --merge -d [sql:]directory [-P dbprefix] --source-dir directory --source-prefix
    624     dbprefix [-@ password-file]
    625   |    For example:
    626   |  $ certutil --merge -d sql:/home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix
    627     serverapp-
    628   |    Running certutil Commands from a Batch File
    629   |    A series of commands can be run sequentially from a text file with the -B
    630   |    command option. The only argument for this specifies the input file.
    631   |  $ certutil -B -i /path/to/batch-file
    632   | NSS Database Types
    633   |    NSS originally used BerkeleyDB databases to store security information.
    634   |    The last versions of these legacy databases are:
    635   |      o cert8.db for certificates
    636   |      o key3.db for keys
    637   |      o secmod.db for PKCS #11 module information
    638   |    BerkeleyDB has performance limitations, though, which prevent it from
    639   |    being easily used by multiple applications simultaneously. NSS has some
    640   |    flexibility that allows applications to use their own, independent
    641   |    database engine while keeping a shared database and working around the
    642   |    access issues. Still, NSS requires more flexibility to provide a truly
    643   |    shared security database.
    644   |    In 2009, NSS introduced a new set of databases that are SQLite databases
    645   |    rather than BerkleyDB. These new databases provide more accessibility and
    646   |    performance:
    647   |      o cert9.db for certificates
    648   |      o key4.db for keys
    649   |      o pkcs11.txt, which is listing of all of the PKCS #11 modules contained
    650   |        in a new subdirectory in the security databases directory
    651   |    Because the SQLite databases are designed to be shared, these are the
    652   |    shared database type. The shared database type is preferred; the legacy
    653   |    format is included for backward compatibility.
    654   |    By default, the tools (certutil, pk12util, modutil) assume that the given
    655   |    security databases follow the more common legacy type. Using the SQLite
    656   |    databases must be manually specified by using the sql: prefix with the
    657   |    given security directory. For example:
    658   |  $ certutil -L -d sql:/home/my/sharednssdb
    659   |    To set the shared database type as the default type for the tools, set the
    660   |    NSS_DEFAULT_DB_TYPE environment variable to sql:
    661   |  export NSS_DEFAULT_DB_TYPE="sql"
    662   |    This line can be set added to the ~/.bashrc file to make the change
    663   |    permanent.
    664   |    Most applications do not use the shared database by default, but they can
    665   |    be configured to use them. For example, this how-to article covers how to
    666   |    configure Firefox and Thunderbird to use the new shared NSS databases:
    667   |      o https://wiki.mozilla.org/NSS_Shared_DB_Howto
    668   |    For an engineering draft on the changes in the shared NSS databases, see
    669   |    the NSS project wiki:
    670   |      o https://wiki.mozilla.org/NSS_Shared_DB
    671   | See Also
    672   |    pk12util (1)
    673   |    modutil (1)
    674   |    certutil has arguments or operations that use features defined in several
    675   |    IETF RFCs.
    676   |      o `http://tools.ietf.org/html/rfc5280 <https://datatracker.ietf.org/doc/html/rfc5280>`__
    677   |      o `http://tools.ietf.org/html/rfc1113 <https://datatracker.ietf.org/doc/html/rfc1113>`__
    678   |      o `http://tools.ietf.org/html/rfc1485 <https://datatracker.ietf.org/doc/html/rfc1485>`__
    679   |    The NSS wiki has information on the new database design and how to
    680   |    configure applications to use it.
    681   |      o https://wiki.mozilla.org/NSS_Shared_DB_Howto
    682   |      o https://wiki.mozilla.org/NSS_Shared_DB
    683   | Additional Resources
    684   |    For information about NSS and other tools related to NSS (like JSS), check
    685   |    out the NSS project wiki at
    686   |   
    687     [1]\ `http://www.mozilla.org/projects/security/pki/nss/ <https://www.mozilla.org/projects/security/pki/nss/>`__.
    688     The NSS site relates
    689   |    directly to NSS code changes and releases.
    690   |    Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto
    691   |    IRC: Freenode at #dogtag-pki
    692   | Authors
    693   |    The NSS tools were written and maintained by developers with Netscape, Red
    694   |    Hat, and Sun.
    695   |    Authors: Elio Maldonado <emaldona@redhat.com>, Deon Lackey
    696   |    <dlackey@redhat.com>.
    697   | Copyright
    698   |    (c) 2010, Red Hat, Inc. Licensed under the GNU Public License version 2.
    699   | References
    700   |    Visible links
    701   |    1.
    702     `http://www.mozilla.org/projects/security/pki/nss/ <https://www.mozilla.org/projects/security/pki/nss/>`__