certutil Commands Reference
Essential certutil commands for managing NSS certificate databases
🗄️ Database Management
Create new NSS database
certutil -N -d sql:/path/to/databaseCreates a new certificate database. You'll be prompted for a password to protect the database.
Create database with empty password
certutil -N -d sql:/path/to/database --empty-password⚠️ Warning: No password protection. Only for non-sensitive testing.
Verify database integrity
certutil -V -d sql:/path/to/database -n "Certificate Nickname"📋 Listing Certificates
List all certificates
certutil -L -d sql:/path/to/databaseShows nickname and trust flags (C=SSL CA, T=Email CA, P=Object Signing CA).
List certificates in Firefox profile
certutil -L -d sql:~/.mozilla/firefox/PROFILE.defaultReplace PROFILE with your Firefox profile name. Find it in ~/.mozilla/firefox/profiles.ini
List certificates in Chrome/Chromium
certutil -L -d sql:~/.pki/nssdbShow detailed certificate information
certutil -L -d sql:/path/to/database -n "Certificate Nickname"Displays full certificate details including subject, issuer, validity, and extensions.
Show certificate in ASCII (PEM) format
certutil -L -d sql:/path/to/database -n "Certificate Nickname" -a➕ Adding Certificates
Add CA certificate (trusted root)
certutil -A -d sql:/path/to/database \
-n "My CA" -t "C,," -i ca-cert.pemTrust flags: C=Trusted CA for SSL, T=Email, P=Object signing
Add server certificate
certutil -A -d sql:/path/to/database \
-n "My Server Cert" -t ",," -i server-cert.pemServer certificates typically have no trust flags (,,).
Add certificate and private key (PKCS#12)
certutil -A -d sql:/path/to/database -i cert.p12 -n "My Cert"Trust specific certificate for SSL
certutil -A -d sql:/path/to/database \
-n "Trusted Server" -t "P,," -i server.pemP = Trusted peer (for server certificates).
🗑️ Deleting Certificates
Delete certificate by nickname
certutil -D -d sql:/path/to/database -n "Certificate Nickname"Delete certificate and private key
certutil -F -d sql:/path/to/database -n "Certificate Nickname"Removes both certificate and associated private key.
📤 Exporting Certificates
Export certificate to PEM
certutil -L -d sql:/path/to/database \
-n "Certificate Nickname" -a > cert.pemExport certificate to DER (binary)
certutil -L -d sql:/path/to/database \
-n "Certificate Nickname" -r > cert.derExport certificate and key to PKCS#12
pk12util -o cert.p12 -d sql:/path/to/database \
-n "Certificate Nickname"Uses pk12util (part of NSS tools). You'll be prompted for export password.
📥 Importing Certificates
Import PKCS#12 file
pk12util -i cert.p12 -d sql:/path/to/databaseImports certificate and private key from PKCS#12 file.
Import PEM certificate
certutil -A -d sql:/path/to/database \
-n "Imported Cert" -t ",," -a -i cert.pemImport DER certificate
certutil -A -d sql:/path/to/database \
-n "Imported Cert" -t ",," -i cert.der🔒 Trust Management
Modify certificate trust
certutil -M -d sql:/path/to/database \
-n "Certificate Nickname" -t "CT,C,C"Sets trust for SSL, Email, and Object Signing. Each position has flags:p=Valid peer, P=Trusted peerc=Valid CA, C=Trusted CAT=Trusted CA for issuing client certsu=Certificate can be used for authentication
Remove trust (but keep certificate)
certutil -M -d sql:/path/to/database \
-n "Certificate Nickname" -t ",,"Trust for SSL only
certutil -M -d sql:/path/to/database \
-n "Certificate Nickname" -t "C,,"✅ Certificate Validation
Verify certificate is valid
certutil -V -d sql:/path/to/database \
-n "Certificate Nickname" -u VUsage flags: V=SSL Server, C=SSL Client, S=Email Signer
Validate at specific time
certutil -V -d sql:/path/to/database \
-n "Certificate Nickname" -b 2501010000ZDate format: YYMMDDHHmmZ (e.g., 2501010000Z = Jan 1, 2025 00:00 UTC)
Check certificate chain
certutil -O -d sql:/path/to/database \
-n "Certificate Nickname"Shows the complete certificate chain up to the root CA.
🔑 Key and CSR Generation
Generate RSA key pair
certutil -G -d sql:/path/to/database \
-z /dev/urandom -g 2048-g specifies key size (2048, 3072, or 4096 bits).
Create certificate request (CSR)
certutil -R -d sql:/path/to/database \
-s "CN=example.com,O=My Organization,C=US" \
-o request.csr -aCreates CSR with specified subject. -a outputs in ASCII (PEM) format.
Create self-signed certificate
certutil -S -d sql:/path/to/database \
-n "Self Signed" -s "CN=localhost" \
-t "C,," -x -v 12-x=self-signed, -v 12=valid for 12 months
📁 Common Database Locations
- Linux:
~/.mozilla/firefox/PROFILE.default/ - macOS:
~/Library/Application Support/Firefox/Profiles/PROFILE.default/ - Windows:
%APPDATA%\Mozilla\Firefox\Profiles\PROFILE.default\
- Linux:
~/.pki/nssdb/ - Some systems:
~/.config/chromium/Default/
/etc/pki/nssdb/(RHEL/CentOS/Fedora)/usr/share/pki/nssdb/(some distributions)
- Modern: Use
sql:prefix (SQLite-based) - Legacy: Use
dbm:prefix (Berkeley DB, deprecated) - Files:
cert9.db,key4.db,pkcs11.txt
🏷️ Trust Flags Reference
Trust flags format: SSL,Email,ObjectSigning
p- Valid peerP- Trusted peerc- Valid CAC- Trusted CA (can issue certs)T- Trusted CA for client certsu- User cert (can authenticate)
C,,- Trusted SSL CA onlyCT,C,C- Trusted for all purposesP,,- Trusted SSL peer,,- No special trustu,u,u- User certificate