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