CERTUTIL(1)
π CERTUTIL(1) π
okay bestie, so this is a page from the NSS Security Tools manual, and it's literally the whole guide to certutil β the tool that manages your keys and certs in NSS databases AND other NSS tokens. buckle up, it's a long one π«Ά
β¨ NAME β¨
certutil β Manage keys and certificate in both NSS databases and other NSS tokens π
πΈ SYNOPSIS πΈ
certutil [options] [[arguments]]
π§ STATUS π§
ngl, this documentation is still work in progress. if you wanna help, please contribute to the initial review in Mozilla NSS bug 836477[1] π
π¦ DESCRIPTION π¦
The Certificate Database Tool, certutil, is a command-line utility that can create and modify certificate and key databases. periodt. it can specifically:
- list, generate, modify, or delete certificates
- create or change the password
- generate new public and private key pairs
- display the contents of the key database
- delete key pairs within the key database
Certificate issuance β which is part of the whole key and certificate management process β requires that keys and certificates be created in the key database. this doc talks about certificate and key database management. for the security module database management tea, see the modutil manpage. β
π COMMAND OPTIONS AND ARGUMENTS π
Running certutil always requires one and only one command option to specify the type of certificate operation. each command option may take zero or more arguments. the command option -H will list all the command options and their relevant arguments. iykyk π
π Command Options π
-Aβ Add an existing certificate to a certificate database. the certificate database should already exist; if one is not present, this command option will initialize one by default. no cap.-Bβ Run a series of commands from the specified batch file. this requires the-iargument.-Cβ Create a new binary certificate file from a binary certificate request file. use the-iargument to specify the certificate request file. if this argument is not used,certutilprompts for a filename.-Dβ Delete a certificate from the certificate database. bye bestie π--renameβ Change the database nickname of a certificate.-Eβ Add an email certificate to the certificate database.-Fβ Delete a private key and the associated certificate from a database. specify the key to delete with the-nargument or the-kargument. specify the database from which to delete the key with the-dargument.
some smart cards do not let you remove a public key you have generated. in such a case, only the private key is deleted from the key pair. π
-Gβ Generate a new public and private key pair within a key database. the key database should already exist; if one is not present, this command option will initialize one by default. some smart cards can store only one key pair. if you create a new key pair for such a card, the previous pair is overwritten. so like, careful. β οΈ-Hβ Display a list of the command options and arguments. the cheat sheet, basically.-Kβ List the key ID of keys in the key database. a key ID is the modulus of the RSA key or the publicValue of the DSA key. IDs are displayed in hexadecimal (0xis not shown).-Lβ List all the certificates, or display information about a named certificate, in a certificate database. use the-htokenname argument to specify the certificate database on a particular hardware or software token.-Mβ Modify a certificate's trust attributes using the values of the-targument.-Nβ Create new certificate and key databases. fresh start energy β¨-Oβ Print the certificate chain.-Rβ Create a certificate request file that can be submitted to a Certificate Authority (CA) for processing into a finished certificate. output defaults to standard out unless you use-ooutput-file argument. use the-aargument to specify ASCII output.-Sβ Create an individual certificate and add it to a certificate database.-Tβ Reset the key database or token.-Uβ List all available modules or print a single named module.-Vβ Check the validity of a certificate and its attributes. the vibe check, but for certs π-Wβ Change the password to a key database.--mergeβ Merge two databases into one.--upgrade-mergeβ Upgrade an old database and merge it into a new database. this is used to migrate legacy NSS databases (cert8.dbandkey3.db) into the newer SQLite databases (cert9.dbandkey4.db). glow-up for your databases fr fr π«
π Arguments π
Arguments modify a command option and are usually lower case, numbers, or symbols.
-aβ Use ASCII format or allow the use of ASCII format for input or output. this formatting follows RFC 1113. for certificate requests, ASCII output defaults to standard output unless redirected.--simple-self-signedβ When printing the certificate chain, don't search for a chain if issuer name equals to subject name.-bvalidity-time β Specify a time at which a certificate is required to be valid. use when checking certificate validity with the-Voption. the format of the validity-time argument isYYMMDDHHMMSS[+HHMM|-HHMM|Z], which allows offsets to be set relative to the validity end time. specifying seconds (SS) is optional. when specifying an explicit time, use aZat the end of the term,YYMMDDHHMMSSZ, to close it. when specifying an offset time, useYYMMDDHHMMSS+HHMMorYYMMDDHHMMSS-HHMMfor adding or subtracting time, respectively.
if this option is not used, the validity check defaults to the current system time. β°
-cissuer β Identify the certificate of the CA from which a new certificate will derive its authenticity. use the exact nickname or alias of the CA certificate, or use the CA's email address. bracket the issuer string with quotation marks if it contains spaces.-d[prefix]directory β Specify the database directory containing the certificate and key database files.
certutil supports two types of databases: the legacy security databases (cert8.db, key3.db, and secmod.db) and new SQLite databases (cert9.db, key4.db, and pkcs11.txt).
NSS recognizes the following prefixes:
sql:requests the sql-lite database
If no prefix is specified the default type is retrieved from NSS_DEFAULT_DB_TYPE. if NSS_DEFAULT_DB_TYPE is not set then sql: is the default. ποΈ
--dump-ext-valOID β For single cert, print binary DER encoding of extension OID.-eβ Check a certificate's signature during the process of validating a certificate.--emailemail-address β Specify the email address of a certificate to list. used with the-Lcommand option.--extGenericOID:critical-flag:filename[,OID:critical-flag:filename]... β Add one or multiple extensions thatcertutilcannot encode yet, by loading their encodings from external files.- OID (example):
1.2.3.4 - critical-flag:
criticalornot-critical - filename: full path to a file containing an encoded extension
- OID (example):
-fpassword-file β Specify a file that will automatically supply the password to include in a certificate or to access a certificate database. this is a plain-text file containing one password. be sure to prevent unauthorized access to this file. π seriously, lock it down.-gkeysize β Set a key size to use when generating new public and private key pairs. the minimum is512bits and the maximum is16384bits. the default is2048bits. any size between the minimum and maximum is allowed.-htokenname β Specify the name of a token to use or act on. if not specified the default token is the internal database slot.
The name can also be a PKCS #11 URI. for example, the NSS internal certificate store can be unambiguously specified as "pkcs11:token=NSS%20Certificate%20DB". for details about the format, see RFC 7512. π
-iinput_file β Pass an input file to the command. depending on the command option, an input file can be a specific certificate, a certificate request file, or a batch file of commands.-kkey-type-or-id β Specify the type or specific ID of a key.
The valid key type options are rsa, dsa, ec, or all. the default value is rsa. specifying the type of key can avoid mistakes caused by duplicate nicknames. giving a key type generates a new key pair; giving the ID of an existing key reuses that key pair (which is required to renew certificates). π
-lβ Display detailed information when validating a certificate with the-Voption.-mserial-number β Assign a unique serial number to a certificate being created. this operation should be performed by a CA. if no serial number is provided a default serial number is made from the current time. serial numbers are limited to integers.-nnickname β Specify the nickname of a certificate or key to list, create, add to a database, modify, or validate. bracket the nickname string with quotation marks if it contains spaces.
The nickname can also be a PKCS #11 URI. for example, if you have a certificate named "my-server-cert" on the internal certificate store, it can be unambiguously specified as "pkcs11:token=NSS%20Certificate%20DB;object=my-server-cert". for details about the format, see RFC 7512. β¨
-ooutput-file β Specify the output file name for new certificates or binary certificate requests. bracket the output-file string with quotation marks if it contains spaces. if this argument is not used the output destination defaults to standard output.-PdbPrefix β Specify the prefix used on the certificate and key database file. this argument is provided to support legacy servers. most applications do not use a database prefix.-pphone β Specify a contact telephone number to include in new certificates or certificate requests. bracket this string with quotation marks if it contains spaces. π-qpqgfile or curve-name β Read an alternate PQG value from the specified file when generating DSA key pairs. if this argument is not used,certutilgenerates its own PQG value. PQG files are created with a separate DSA utility.
Elliptic curve name is one of the ones from nistp256, nistp384, nistp521, curve25519.
okay that's the first chunk bestie, and there's literally so much more coming β don't go anywhere π
If your token is out here supporting more curves, then these extra ones are also on the menu: sect163k1, nistk163, sect163r1, sect163r2, nistb163, sect193r1, sect193r2, sect233k1, nistk233, sect233r1, nistb233, sect239k1, sect283k1, nistk283, sect283r1, nistb283, sect409k1, nistk409, sect409r1, nistb409, sect571k1, nistk571, sect571r1, nistb571, secp160k1, secp160r1, secp160r2, secp192k1, secp192r1, nistp192, secp224k1, secp224r1, nistp224, secp256k1, secp256r1, secp384r1, secp521r1, prime192v1, prime192v2, prime192v3, prime239v1, prime239v2, prime239v3, c2pnb163v1, c2pnb163v2, c2pnb163v3, c2pnb176v1, c2tnb191v1, c2tnb191v2, c2tnb191v3, c2pnb208w1, c2tnb239v1, c2tnb239v2, c2tnb239v3, c2pnb272w1, c2pnb304w1, c2tnb359w1, c2pnb368w1, c2tnb431r1, secp112r1, secp112r2, secp128r1, secp128r2, sect113r1, sect113r2, sect131r1, sect131r2
Like, that's a whole buffet of curve names, bestie. Pick your fighter. π¦
-rβ when you're listing info about a cert with-L, this shows you that cert's binary DER encoding. Raw bytes, no filter, it's giving very "here's the source material." π₯-ssubject β names a specific certificate owner for new certs or cert requests. If your string has spaces in it, wrap it in quotation marks or it'll get chopped up (rude). The subject identification format follows RFC #1485.-ttrustargs β sets the trust attributes, either to modify on an existing cert, or to apply to a cert when you're creating it or adding it to a database. Every cert has three trust categories, and they're expressed in this order: SSL, email, object signing. In each category position you can usenone,any, or all of the attribute codes:pβ Valid peerPβ Trusted peer (impliesp)cβ Valid CACβ Trusted CA (impliesc)Tβ trusted CA for client authentication (ssl server only)
The attribute codes for the categories get separated by commas, and the whole set gets wrapped in quotation marks. For example:
-t "TC,C,T"
Use the -L option to peek at the current certs and their trust attributes in a certificate database. π
Heads up bestie: the output of-Lmight include auflag, and that means there's a private key associated with the certificate. It's a dynamic flag β you literally cannot set it withcertutil. Not even a little. π
-ucertusage β tellscertutilwhat usage context to apply when validating a cert with the-Voption. The contexts are:C(as an SSL client)V(as an SSL server)L(as an SSL CA)A(as Any CA)Y(Verify CA)S(as an email signer)R(as an email recipient)O(as an OCSP status responder)J(as an object signer)I(as an IPSEC user)
-vvalid-months β how many months a new cert stays valid. The validity period starts at the current system time, unless you've added or subtracted an offset with-w. Don't pass this argument and the default validity period is three months. Cute little starter window. π-woffset-months β an offset from the current system time, in months, for when a cert's validity period begins. Use it when creating the cert or adding it to a database. Express the offset in integers, and use a minus sign (-) if you want it negative. Skip this argument and the validity period begins at the current system time. The length of the validity period is set with the-vargument.-Xβ forces the key and certificate database to open in read-write mode. This one's used with the-Uand-Lcommand options.-xβ usecertutilto generate the signature for a cert being created or added to a database, instead of getting a signature from a separate CA. DIY era. π-yexp β sets an alternate exponent value to use when generating a new RSA public key for the database, instead of the default value of65537. The alternate values you can pick from are3and17.--pssβ restricts the generated certificate (with the-Soption) or certificate request (with the-Roption) to be used with the RSA-PSS signature scheme. This only works when the private key of the certificate or certificate request is RSA. No RSA key, no party. β¨--pss-signβ signs the generated certificate with the RSA-PSS signature scheme (with the-Cor-Soption). This only works when the private key of the signer's certificate is RSA. And lowkey, if the signer's certificate is already restricted to RSA-PSS, you don't even need to specify this option β it's already that girl.-znoise-file β reads a seed value from the file you specify to generate a new private and public key pair. This argument is what makes it possible to use hardware-generated seed values, or to manually create a value from the keyboard. Minimum file size is 20 bytes. Don't skimp. π-ZhashAlg β specify the hash algorithm to use with the-C,-Sor-Rcommand options. Possible keywords:MD2MD4MD5SHA1SHA224SHA256SHA384SHA512
-0SSO_password β sets a site security officer password on a token. (That's a zero, bestie, not a letter O. We stay vigilant. π)-1|--keyUsagekeyword,keyword β sets an X.509 V3 Certificate Type Extension in the certificate. Several keywords are available:digitalSignaturenonRepudiationkeyEnciphermentdataEnciphermentkeyAgreementcertSigningcrlSigningcritical
-2β adds a basic constraint extension to a certificate that's being created or added to a database. This extension supports the certificate chain verification process.certutilprompts you for the certificate constraint extension to select.
X.509 certificate extensions are described in RFC 5280.
-3β adds an authority key ID extension to a certificate that's being created or added to a database. This extension supports identifying a particular certificate, from among multiple certificates associated with one subject name, as the correct issuer of a certificate. The Certificate Database Tool will prompt you to select the authority key ID extension.
X.509 certificate extensions are described in RFC 5280.
-4β adds a CRL distribution point extension to a certificate that's being created or added to a database. This extension identifies the URL of a certificate's associated certificate revocation list (CRL).certutilprompts you for the URL.
X.509 certificate extensions are described in RFC 5280.
-5|--nsCertTypekeyword,keyword β adds an X.509 V3 certificate type extension to a certificate that's being created or added to the database. Several keywords are available:sslClientsslServersmimeobjectSigningsslCAsmimeCAobjectSigningCAcritical
X.509 certificate extensions are described in RFC 5280.
-6|--extKeyUsagekeyword,keyword β adds an extended key usage extension to a certificate that's being created or added to the database. Several keywords are available:serverAuthclientAuthcodeSigningemailProtectiontimeStampocspResponderstepUpmsTrustListSigncriticalx509AnyipsecIKEipsecIKEEndipsecIKEIntermediateipsecEndipsecTunnelipsecUser
X.509 certificate extensions are described in RFC 5280.
-7emailAddrs β adds a comma-separated list of email addresses to the subject alternative name extension of a certificate or certificate request that's being created or added to the database. Subject alternative name extensions are described in Section 4.2.1.7 of RFC 3280.-8dns-names β adds a comma-separated list of DNS names to the subject alternative name extension of a certificate or certificate request that's being created or added to the database. Subject alternative name extensions are described in Section 4.2.1.7 of RFC 3280.--extAIAβ adds the Authority Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extSIAβ adds the Subject Information Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extCPβ adds the Certificate Policies extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extPMβ adds the Policy Mappings extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extPCβ adds the Policy Constraints extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extIAβ adds the Inhibit Any Policy Access extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extSKIDβ adds the Subject Key ID extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extNCβ adds a Name Constraint extension to the certificate. X.509 certificate extensions are described in RFC 5280.--extSANtype:name[,type:name]... β creates a Subject Alt Name extension with one or multiple names. Obsessed with the flexibility ngl. π-type: directory, dn, dns, edi, ediparty, email, ip, ipaddr, other, registerid, rfc822, uri, x400, x400addr
--empty-passwordβ uses an empty password when creating a new certificate database with-N. (Yes bestie, empty. That's a choice and it's yours to make. π)--keyAttrFlagsattrflags β PKCS #11 key Attributes. Comma separated list of key attribute flags, selected from the following list of choices:{token | session}{public | private}{sensitive | insensitive}{modifiable | unmodifiable}{extractable | unextractable}--keyOpFlagsOnopflags,--keyOpFlagsOffopflags β PKCS #11 key Operation Flags. Comma separated list of one or more of the following:{token | session}{public | private}{sensitive | insensitive}{modifiable | unmodifiable}{extractable | unextractable}--new-nnickname β a new nickname, used when renaming a certificate. Glow-up via name change, iconic. π--source-dircertdir β identifies the certificate database directory to upgrade.--source-prefixcertdir β gives the prefix of the certificate and key databases to upgrade.
--upgrade-iduniqueID β hand over the unique ID of the database you wanna upgrade, bestie π«Ά--upgrade-token-namename β sets the name of the token to use while it's mid-upgrade β¨-@pwfile β point it at a password file for the database being upgraded π
π USAGE AND EXAMPLES π
okay so most of the command options in these examples have way more arguments available than what's shown. The arguments that are here are either the most common ones or they're there to illustrate a specific scenario. Wanna see the whole list of arguments for any command option? Use the -H option, periodt. π
π Creating New Security Databases π
Certificates, keys, and security modules related to managing certificates live in three related databases:
cert8.dborcert9.dbkey3.dborkey4.dbsecmod.dborpkcs11.txt
These databases have to be created before you can generate certificates or keys. no cap. πΈ
certutil -N -d directory
π¦ Creating a Certificate Request π¦
A certificate request contains most or all of the info that gets used to generate the final certificate. You submit this request separately to a certificate authority, and then it gets approved by some mechanism (either automatically or by human review π). Once the request is approved, then the certificate gets generated.
$ certutil -R -k key-type-or-id [-q pqgfile|curve-name] -g key-size -s subject [-h tokenname] -d directory [-p phone] [-o output-file] [-a]
The -R command options requires four arguments:
-kto specify either the key type to generate or, when renewing a certificate, the existing key pair to use-gto set the keysize of the key to generate-sto set the subject name of the certificate-dto give the security database directory
Your new certificate request can be output in ASCII format (-a) or written straight to a specified file (-o). iconic behavior. β¨
For example:
$ certutil -R -k rsa -g 1024 -s "CN=John Smith,O=Example Corp,L=Mountain View,ST=California,C=US" -d $HOME/nssdb -p 650-555-0123 -a -o cert.cer
Generating key. This may take a few moments...
π Creating a Certificate π
A valid certificate must be issued by a trusted CA. You can do this by specifying a CA certificate (-c) that's stored in the certificate database. If there's no CA key pair available, you can make a self-signed certificate using the -x argument together with the -S command option. it's giving self-made royalty π
$ certutil -S -k rsa|dsa|ec -n certname -s subject [-c issuer |-x] -t trustargs -d directory [-m serial-number] [-v valid-months] [-w offset-months] [-p phone] [-1] [-2] [-3] [-4] [-5 keyword] [-6 keyword] [-7 emailAddress] [-8 dns-names] [--extAIA] [--extSIA] [--extCP] [--extPM] [--extPC] [--extIA] [--extSKID]
That series of numbers and the --ext* options set certificate extensions that can be added to the certificate when it's generated by the CA. Heads up: interactive prompts will result π
For example, this creates a self-signed certificate:
$ certutil -S -s "CN=Example CA" -n my-ca-cert -x -t "C,C,C" -1 -2 -5 -m 3650
The interactive prompts for key usage and whether any extensions are critical, plus the responses, have been omitted for brevity. (not me leaving out the yapping π)
From there, new certificates can reference the self-signed certificate:
$ certutil -S -s "CN=My Server Cert" -n my-server-cert -c "my-ca-cert" -t ",," -1 -5 -6 -8 -m 730
π§ Generating a Certificate from a Certificate Request π§
When a certificate request gets created, you can generate a certificate by using the request and then referencing a certificate authority signing certificate (that's the issuer specified in the -c argument). The issuing certificate must be in the certificate database in the specified directory. fr fr.
certutil -C -c issuer -i cert-request-file -o output-file [-m serial-number] [-v valid-months] [-w offset-months] -d directory [-1] [-2] [-3] [-4] [-5 keyword] [-6 keyword] [-7 emailAddress] [-8 dns-names]
For example:
$ certutil -C -c "my-ca-cert" -i /home/certs/cert.req -o cert.cer -m 010 -v 12 -w 1 -d $HOME/nssdb -1 nonRepudiation,dataEncipherment -5 sslClient -6 clientAuth -7 jsmith@example.com
π Listing Certificates π
The -L command option lists all of the certificates listed in the certificate database. The path to the directory (-d) is required.
$ certutil -L -d /home/my/sharednssdb
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
CA Administrator of Instance pki-ca1's Example Domain ID u,u,u
TPS Administrator's Example Domain ID u,u,u
Google Internet Authority ,,
Certificate Authority - Example Domain CT,C,C
Using extra arguments with -L can return and print the info for a single, specific certificate. For example, the -n argument passes the certificate name, while the -a argument prints the certificate in ASCII format:
$ certutil -L -d $HOME/nssdb -a -n my-ca-cert
-----BEGIN CERTIFICATE-----
MIIB1DCCAT2gAwIBAgICDkIwDQYJKoZIhvcNAQEFBQAwFTETMBEGA1UEAxMKRXhh
bXBsZSBDQTAeFw0xMzAzMTMxOTEwMjlaFw0xMzA2MTMxOTEwMjlaMBUxEzARBgNV
BAMTCkV4YW1wbGUgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJ4Kzqvz
JyBVgFqDXRYSyTBNw1DrxUU/3GvWA/ngjAwHEv0Cul/6sO/gsCvnABHiH6unns6x
XRzPORlC2WY3gkk7vmlsLvYpyecNazAi/NAwVnU/66HOsaoVFWE+gBQo99UrN2yk
0BiK/GMFlLm5dXQROgA9ZKKyFdI0LIXtf6SbAgMBAAGjMzAxMBEGCWCGSAGG+EIB
AQQEAwIHADAMBgNVHRMEBTADAQH/MA4GA1UdDwEB/wQEAwICBDANBgkqhkiG9w0B
AQUFAAOBgQA6chkzkACN281d1jKMrc+RHG2UMaQyxiteaLVZO+Ro1nnRUvseDf09
XKYFwPMJjWCihVku6bw/ihZfuMHhxK22Nue6inNQ6eDu7WmrqL8z3iUrQwxs+WiF
ob2rb8XRVVJkzXdXxlk4uo3UtNvw8sAz7sWD71qxKaIHU5q49zijfg==
-----END CERTIFICATE-----
For a human-readable display:
$ certutil -L -d $HOME/nssdb -n my-ca-cert
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 3650 (0xe42)
Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
Issuer: "CN=Example CA"
Validity:
Not Before: Wed Mar 13 19:10:29 2013
Not After : Thu Jun 13 19:10:29 2013
Subject: "CN=Example CA"
Subject Public Key Info:
Public Key Algorithm: PKCS #1 RSA Encryption
RSA Public Key:
Modulus:
9e:0a:ce:ab:f3:27:20:55:80:5a:83:5d:16:12:c9:30:
4d:c3:50:eb:c5:45:3f:dc:6b:d6:03:f9:e0:8c:0c:07:
12:fd:02:ba:5f:fa:b0:ef:e0:b0:2b:e7:00:11:e2:1f:
ab:a7:9e:ce:b1:5d:1c:cf:39:19:42:d9:66:37:82:49:
3b:be:69:6c:2e:f6:29:c9:e7:0d:6b:30:22:fc:d0:30:
56:75:3f:eb:a1:ce:b1:aa:15:15:61:3e:80:14:28:f7:
d5:2b:37:6c:a4:d0:18:8a:fc:63:05:94:b9:b9:75:74:
11:3a:00:3d:64:a2:b2:15:d2:34:2c:85:ed:7f:a4:9b
Exponent: 65537 (0x10001)
Signed Extensions:
Name: Certificate Type
Data: none
Name: Certificate Basic Constraints
Data: Is a CA with no maximum path length.
Name: Certificate Key Usage
Critical: True
Usages: Certificate Signing
Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
Signature:
3a:72:19:33:90:00:8d:db:cd:5d:d6:32:8c:ad:cf:91:
1c:6d:94:31:a4:32:c6:2b:5e:68:b5:59:3b:e4:68:d6:
79:d1:52:fb:1e:0d:fd:3d:5c:a6:05:c0:f3:09:8d:60:
a2:85:59:2e:e9:bc:3f:8a:16:5f:b8:c1:e1:c4:ad:b6:
36:e7:ba:8a:73:50:e9:e0:ee:ed:69:ab:a8:bf:33:de:
25:2b:43:0c:6c:f9:68:85:a1:bd:ab:6f:c5:d1:55:52:
64:cd:77:57:c6:59:38:ba:8d:d4:b4:db:f0:f2:c0:33:
ee:c5:83:ef:5a:b1:29:a2:07:53:9a:b8:f7:38:a3:7e
Fingerprint (MD5):
86:D8:A5:8B:8A:26:BE:9E:17:A8:7B:66:10:6B:27:80
Fingerprint (SHA1):
48:78:09:EF:C5:D4:0C:BD:D2:64:45:59:EB:03:13:15:F7:A9:D6:F7
Certificate Trust Flags:
SSL Flags:
Valid CA
Trusted CA
User
Email Flags:
Valid CA
Trusted CA
User
Object Signing Flags:
Valid CA
Trusted CA
User
π Listing Keys π
Keys are the original material used to encrypt certificate data. The keys generated for certificates are stored separately, in the key database. iykyk π
To list all keys in the database, use the -K command option and the (required!) -d argument to give the path to the directory.
$ certutil -K -d $HOME/nssdb
certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services "
< 0> rsa 455a6673bde9375c2887ec8bf8016b3f9f35861d Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID
< 1> rsa 40defeeb522ade11090eacebaaf1196a172127df Example Domain Administrator Cert
< 2> rsa 1d0b06f44f6c03842f7d4f4a1dc78b3bcd1b85a5 John Smith user cert
There are ways to narrow down the keys in your search results:
- To return a specific key, use the
-nname argument with the name of the key. - If there are multiple security devices loaded, then the
-htokenname argument can search a specific token or all tokens. - If there are multiple key types available, then the
-kkey-type argument can search a specific type of key, like RSA, DSA, or ECC.
π Listing Security Modules π
The devices that can be used to store certificates β both internal databases and external devices like smart cards β are recognized and used by loading security modules. The -U command option lists all of the security modules listed in the secmod.db database. The path to the directory (-d) is required.
$ certutil -U -d /home/my/sharednssdb
slot: NSS User Private Key and Certificate Services
token: NSS Certificate DB
uri: pkcs11:token=NSS%20Certificate%20DB;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203
slot: NSS Internal Cryptographic Services
token: NSS Generic Crypto Services
uri: pkcs11:token=NSS%20Generic%20Crypto%20Services;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203
β Adding Certificates to the Database β
Existing certificates or certificate requests can be added manually to the certificate database, even if they were generated somewhere else entirely. This uses the -A command option. so versatile π
certutil -A -n certname -t trustargs -d directory [-a] [-i input-file]
For example:
$ certutil -A -n "CN=My SSL Certificate" -t ",," -d /home/my/sharednssdb -i /home/example-certs/cert.cer
Okay so there's a whole other command option that's basically the -A pipeline's sibling, and it's called -E β¨ It exists specifically to add email certificates into the certificate database, and it takes the exact same arguments as -A. The trust args for certs go SSL,S/MIME,Code-signing, which means the middle trust setting is the one that's most about email certificates β though bestie, you can totally set the others too, no gatekeeping π
Like, for example:
$ certutil -E -n "CN=John Smith Email Cert" -t ",P," -d /home/my/sharednssdb -i /home/example-certs/email.cer
ποΈ Deleting Certificates to the Database
You can yeet certificates out of a database with the -D option πΈ The only required things are the security database directory and the certificate's nickname so it knows which one you're removing.
certutil -D -d directory -n "nickname"
For example:
$ certutil -D -d /home/my/sharednssdb -n "my-ssl-cert"
β Validating Certificates
Every certificate carries its own expiration date inside it, so expired ones are, like, trivially rejected π ββοΈ But plot twist: a certificate can also get revoked before it ever hits its expiration date. So if you wanna know whether something's been revoked, you have to validate it. Validation is also how you make sure a certificate only gets used for the purposes it was originally issued for β no doing side quests it wasn't built for, bestie.
All of that runs through the -V command option:
certutil -V -n certificate-name [-b time] [-e] [-u cert-usage] -d directory
For example, validating an email certificate:
$ certutil -V -n "John Smith's Email Cert" -e -u S,R -d /home/my/sharednssdb
π§ Modifying Certificate Trust Settings
The trust settings (aka the stuff that decides which operations a certificate is allowed to be used for) can be changed after a certificate has been created or added to the database π This is highkey the most useful for CA certificates, but honestly it can be done to any type of certificate.
certutil -M -n certificate-name -t trust-args -d directory
For example:
$ certutil -M -n "My CA Certificate" -d /home/my/sharednssdb -t "CT,CT,CT"
π³ Printing the Certificate Chain
Certificates get issued in chains, because every certificate authority has a certificate of its own β so when a CA issues a certificate, it's basically stamping that cert with its own fingerprint π¦ The -O prints the full chain of a certificate, walking from the initial CA (the root CA) through every intermediary CA all the way down to the actual certificate. Iconic lineage behavior, honestly.
So for an email certificate with two CAs in the chain:
$ certutil -d /home/my/sharednssdb -O -n "jsmith@example.com"
"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]
"Thawte Personal Freemail Issuing CA - Thawte Consulting" [CN=Thawte Personal Freemail Issuing CA,O=Thawte Consulting (Pty) Ltd.,C=ZA]
"(null)" [E=jsmith@example.com,CN=Thawte Freemail Member]
π Resetting a Token
The device that stores certificates β and yes, that means both external hardware devices and internal software databases β can be blanked and reused π§ This operation happens on the device that stores the data, NOT directly on the security databases, so you have to reference the location through the token name (-h) and any directory path. And if there's no external token in play, the default value is internal.
certutil -T -d directory -h token-name -0 security-officer-password
Lots of networks have dedicated personnel whose whole job is handling changes to security tokens β they're called the security officer π and this person has to supply the password to access the specified token. For example:
$ certutil -T -d /home/my/sharednssdb -h nethsm -0 secret
π¦ Upgrading or Merging the Security Databases
A lot of networks and applications are still out here running the older BerkeleyDB versions of the certificate database (cert8.db) π Databases can be upgraded to the new SQLite version of the database (cert9.db) using the --upgrade-merge command option β or, existing databases can be merged with the new cert9.db databases using the ---merge command.
The --upgrade-merge command has to give information about the original database first, and then use the standard arguments (like -d) to give the info about the new databases. It also needs the information the tool uses for the process of upgrading and writing over the original database.
certutil --upgrade-merge -d directory [-P dbprefix] --source-dir directory --source-prefix dbprefix --upgrade-id id --upgrade-token-name name [-@ password-file]
For example:
$ certutil --upgrade-merge -d /home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix serverapp- --upgrade-id 1 --upgrade-token-name internal
The --merge command only needs info about where the original database lives β because it doesn't change the format of the database, it can just write over the information without doing the interim step first. Efficiency queen π
certutil --merge -d directory [-P dbprefix] --source-dir directory --source-prefix dbprefix [-@ password-file]
For example:
$ certutil --merge -d /home/my/sharednssdb --source-dir /opt/my-app/alias/ --source-prefix serverapp-
π Running certutil Commands from a Batch File
A whole series of commands can be run one after another, sequentially, from a text file using the -B command option π The only argument for this one specifies the input file.
$ certutil -B -i /path/to/batch-file
ποΈ NSS DATABASE TYPES β¨
NSS originally used BerkeleyDB databases to store security information. The last versions of these legacy databases are:
cert8.dbfor certificateskey3.dbfor keyssecmod.dbfor PKCS #11 module information
BerkeleyDB has performance limitations though, and those limitations stop it from being easily used by multiple applications at the same time π NSS has some flexibility that lets applications use their own independent database engine while still keeping a shared database and working around the access issues. But still β NSS needs more flexibility to provide a truly shared security database.
So in 2009, NSS introduced a whole new set of databases that are SQLite databases instead of BerkeleyDB π¦ These new ones give you more accessibility and performance:
cert9.dbfor certificateskey4.dbfor keyspkcs11.txt, a listing of all of the PKCS #11 modules, contained in a new subdirectory in the security databases directory
Because the SQLite databases are designed to be shared, these are the shared database type. Periodt π
By default, the tools (certutil, pk12util, modutil) assume that the given security databases use the SQLite type.
For an engineering draft on the changes in the shared NSS databases, see the NSS project wiki:
π SEE ALSO
pk12util(1)modutil(1)
certutil has arguments or operations that use features defined in several IETF RFCs.
- http://tools.ietf.org/html/rfc5280
- http://tools.ietf.org/html/rfc1113
- http://tools.ietf.org/html/rfc1485
The NSS wiki has information on the new database design and how to configure applications to use it.
π§° ADDITIONAL RESOURCES π
If you want info about NSS and other tools related to NSS (like JSS), go check out the NSS project wiki at http://www.mozilla.org/projects/security/pki/nss/ πΈ The NSS site relates directly to NSS code changes and releases.
Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto
IRC: Freenode at #dogtag-pki
π AUTHORS
The NSS tools were written and maintained by developers with Netscape, Red Hat, Sun, Oracle, Mozilla, and Google. Legends only, fr fr π«Ά
Authors: Elio Maldonado <emaldona@redhat.com>, Deon Lackey <dlackey@redhat.com>.
π LICENSE
Licensed under the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
π NOTES
- Mozilla NSS bug 836477 β https://bugzilla.mozilla.org/show_bug.cgi?id=836477
and that's the whole page, bestie!! ππβ¨ shoutout to nss-tools, dated 15 October 2026, living in the CERTUTIL(1) section of the manual β go forth and manage your certificates like the main character you are ππ
π¦ where this page comes from
- fedora 43: nss-tools 3.131.0-1.fc43 Β· MPL-2.0
- fedora 44: nss-tools 3.131.0-1.fc44 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms