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