I want to add some root CAs that doesn't come with the default firefox on Ubuntu, but I don't know how.

I tried adding them to the local certificates with certutil, but it didn't work. It messed up my certificates database.

$ certutil -A -d .mozilla/firefox/kek3dogy.default/ -i /usr/local/share/ca-certificates/FNMT_ACRAIZ.crt -n "Certificado Raiz FNMT" -t "TCu,Cuw,Tuw"

and then

$ certutil -L -d .mozilla/firefox/kek3dogy.default/

Certificate Nickname                                         Trust Attributes

Go Daddy Secure Certification Authority                      ,,   
VeriSign Class 3 Secure Server CA - G3                       ,,   
VeriSign Class 3 Extended Validation SSL CA                  ,,   
DigiCert High Assurance CA-3                                 ,,   
GlobalSign Domain Validation CA - G2                         ,,   
GeoTrust SSL CA                                              ,,   
StartCom Class 2 Primary Intermediate Server CA              ,,   
Google Internet Authority                                    ,,   
Certificado Raiz FNMT                                        CT,C,c
USERTrust Legacy Secure Server CA                            ,,   
HP Jetdirect 2B0EAD20                                        ,,   
Akamai Subordinate CA 3                                      ,,   
VeriSign, Inc.                                               ,,   
Thawte SGC CA                                                ,,   
VeriSign Class 3 Secure Server CA - G2                       ,,

The certificate won't show up on Firefox. I tried this several times, even deleting the profile, and it showed up once on the Firefox interface, but completely empty.

Anyways, that's only for a user, and I want to add them system-wide. Is there a system-wide database I can modify? How?

If there is no system-wide database I can modify, I can rely on a X start script (as /etc/X11/Xsession.d/ ones, or a script called by the xdg autostart system on /etc/xdg/autostart/) to modify the user profile at session start, but I need a solution that works. I can't even load certificates on the user profiles from the command line now!

  • Is editing the default profile an option (so that newly added certificates are added when a new profile is created, but old profiles are left unchanged)? – Andrea Corbellini Jan 27 '13 at 11:16
  • No, approximately +100 profiles already exist and new profiles are a rare thing. – Jorge Suárez de Lis Jan 27 '13 at 11:24
  • Can't you generate a new profile folder in Firefox's directory, and then add it to profiles.ini? Then you could add your changes to it, and then copy it and profiles.ini to each user directory. – Wilf Oct 30 '13 at 19:40
  • N.B. You can edit profiles for Firefox by running firefox -p - but you have to close Firefox first. – Wilf Oct 30 '13 at 20:11
  • Nope, there are +100 users with their own already existing profile. They won't like to lose their bookmarks, history, passwords, etc. – Jorge Suárez de Lis Nov 1 '13 at 23:05

The problem here is that Firefox does not have a 'central' location where it looks for certificates. It just looks into the current profile. That's why modifying /usr/share/ca-certificates or other similar directories won't work with Firefox. This is something that has been requested for years; see issues 620373, 449498 and 454036 (and probably there are many others).

So you are left with just two kind of solutions: either modify each profile, or modify the behaviour of Firefox. I know this is not what you are looking for, but there are no ways because Firefox only looks at users' profiles.

Having said that, the solution I would choose is using hard or symbolic links, specifically I'd go with hardlinks. This solution is surely the easiest and probably the better, though I don't have enough information to judge.

What you have to do is basically removing each cert8.db and key3.db files for each profile and replace them with links to the "most complete" cert8.db and key3.db. If you go with hardlinks, the original cert8.db and key3.db will be indistinguishable from the new ones.

Remember to adjust permissions to fit your needs. Most likely, you will need to chmod a+rw so that everybody will be able to add/remove a certificate. If you want only certain users to be able to add/remove certificates, you can create a group, assign the two databases to that group and give +w permission just to the group.

  • Yup, same as I could come up with. It's a bit of a shame for Firefox, imo. – gertvdijk Jan 27 '13 at 18:06
  • But won't overwrite that the user certificates? Aren't the user certificates stored there? – Jorge Suárez de Lis Jan 27 '13 at 20:06
  • @JorgeSuárezdeLis: well, when you delete that files you will loose the certificates. If this is what you mean with "overwriting", then yes. You should first merge all the databases into one and then proceed creating the hardlinks. – Andrea Corbellini Jan 27 '13 at 21:54
  • But... I don't want one user to have the personal certificates of the others! I'm talking now about their certificates, not the certificate authorities. – Jorge Suárez de Lis Jan 27 '13 at 23:18
  • @JorgeSuárezdeLis: sorry, I can't understand: what are personal certificates? – Andrea Corbellini Oct 28 '13 at 17:07

The easiest way is to import the certificate into a sample firefox-profile and then copy the cert8.db to the users you want equip with the certificate.

First import the certificate by hand into the firefox profile of the sample-user. Then copy


into the users firefox-profiles. That's it. If you want to make sure, that new users get the certificate automatically, copy cert8.db to:


Here is an alternative way that doesn't override the existing certificates: [bash fragment for linux systems]

certificateName="MyCA Name" 
for certDB in $(find  ~/.mozilla* ~/.thunderbird -name "cert8.db")
  certDir=$(dirname ${certDB});
  #log "mozilla certificate" "install '${certificateName}' in ${certDir}"
 certutil -A -n "${certificateName}" -t "TCu,Cuw,Tuw" -i ${certificateFile} -d ${certDir}

You may find certutil in the libnss3-tools package (debian/ubuntu).

See also: Programmatic import of CA Certificate

Source: Programmatically Install Certificate into Mozilla

  • +1 but if you upvote this, you should perhaps also upvote the answers on StackOverflow which this was derived from. – tripleee Apr 25 '14 at 12:50

Contrary to popular belief, you can get Firefox to look at the system certificates instead its own hard-coded set.

To do this, you will want to use a package called p11-kit. p11-kit provides a drop-in replacement for libnssckbi.so, the shared library that contains the hardcoded set of certificates. The p11-kit version instead reads the certificates from the system certificate store.

Since Firefox ships with its own version of libnssckbi.so, you'll need to track it down and replace it instead of the version provided in libnss3:

sudo mv /usr/lib/firefox/libnssckbi.so /usr/lib/firefox/libnssckbi.so.bak
sudo ln -s /usr/lib/x86_64-linux-gnu/pkcs11/p11-kit-trust.so /usr/lib/firefox/libnssckbi.so

Next, delete the ~/.pki directory to get Firefox to refresh its certificate database (causing it to pull in the system certs) upon restarting Firefox. Note: this will delete any existing certificates in the store, so if have custom ones that you added manually, you might want to back up that folder and then re-import them.

  • Oh, wow, that's a bit of a hack, but +1. You may want to add a dpkg-divert step to avoid APT overwriting the file again when you upgrade Firefox package. – gertvdijk May 20 '18 at 14:06

One of the features of the CCK Wizard Firefox add-on is importing CA certs. I use this add-on to create a custom add-on that includes a company CA Cert. I then package the custom xpi in a .deb on the internal repository that all the workstations get updates from.

CCK Wizard

EDIT: In order to package the xpi for Ubuntu, you need to create a package that includes the directory /usr/lib/firefox-addons/extensions/[addon-name@servername] and unzip the entire contents of the xpi into this directory. For instance if you name your addon foobarbaz and the server you have it set to update from (if you were to enable that function) is intranet.example.com, then the directory would be foobarbaz@intranet.example.com. I never enable the auto update, but instead update the deb in the repo.

  • I prefer this method over the others because it is self-contained and can include a ton of other customizations in one place. The author seems to have removed his extension from AMO though. Now he has it on his own site here, and the latest xpi is here. – Amit Naidu Dec 31 '15 at 20:42

Firefox works after a clean installation. If certificate database in cert8.db is deleted, it is regenerated on next Firefox start. This strongly suggests that there is a system-wide default storage of CA certs.

Firefox's source code shows that built-in CA certs are in fact hard-coded into firefox executable. They reside in security/nss/lib/ckfw/builtins/certdata.txt

So there is no way to install a certificate system-wide. Beware that patching source code may bring up issues with intellectual property rights.


I am using a "User Environment Virtualization" (UEV) application that does this for my users, but you can do this with logon scripts in Windows clients just the same. I won't post all of the code to dynamically find the %APPDATA%\Mozilla\Firefox\%PROFILE% path, but when you do find it, you can import the scripts using some basic commands. I am basically reading the Firefox profiles.ini file to determine the path to the Firefox profile/cert8.db.

You may want to look at using the certutil.exe application. https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil

You can run logon scripts for users that automatically imports the trusted certs from a central location into the Firefox of all users on the system.

Here is the "core" of my certificate import vb script:

If Instr(strLine,"Path=Profiles/") Then
  arrLine = Split(strLine, "/")
  strProfile = strAppData & "\Mozilla\Firefox\Profiles\" & arrLine(1)
  strCertDB = strProfile & "\cert8.db"

  'Verify the DB exists, if not move to the next entry
  If objFSO.FileExists(strCertDB) Then
    'Run certutil command on this database
    strCertCommand1 = "\\SERVERNAME\SHARENAME$\certs\certutil\certutil.exe -A " &_
    "-n MYCA -t ""CT,C,C"" -d " & strProfile & " -i \\SERVERNAME\SHARENAME$\certs\MYCA_Root.cer"

    strCertCommand2 = "\\SERVERNAME\SHARENAME$\certs\certutil\certutil.exe -A " &_
    "-n MYSECONDCA -t ""CT,C,C"" -d " & strProfile & " -i \\SERVERNAME\SHARENAME$\certs\SecondCA_Root.cer"

    strCertCommand3 = "\\SERVERNAME\SHARENAME$\certs\certutil\certutil.exe -A " &_
    "-n MYTHIRDCA -t ""CT,C,C"" -d " & strProfile & " -i \\SERVERNAME\SHARENAME$\certs\ThirdCA_Root.cer"

    'Run the import commands for this Firefox profile
    objShell.Run("%comspec% /c " & strCertCommand1),0,TRUE
    objShell.Run("%comspec% /c " & strCertCommand2),0,TRUE
    objShell.Run("%comspec% /c " & strCertCommand3),0,TRUE

I found out that most of the time and by default if not configured otherwise Firefox uses legacy security databases (cert8.db, key3.db, and secmod.db) that means you will need to use a different command line to inject the certificate into the correct database that Firefox use. (see more from the man of certutil)

so if your system uses the default data base the command should go like this: (dbm)

certutil -A -n "Description Name" -t "CT,C,C" -d dbm:/home/<username>/.mozilla/firefox/<default folder>/ -i certificate.crt

otherwise it should be like this: (sql)

certutil -A -n "Description Name" -t "CT,C,C" -d sql:/home/<username>/.mozilla/firefox/<default folder>/ -i certificate.crt

from man certutil:

-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 newer database

·   dbm: requests the legacy database

If no prefix is specified the default type is retrieved from
  • Using my .pem files with the first certutil command worked. I was looking for automating a single-user setup script and this does the trick. You'll need to apt-get install libnss3-tools to have certutil. – xificurC Jul 6 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.