在Firefox上添加系统范围的证书颁发机构

我想在Ubuntu上添加一些没有默认firefox附带的根CA,但我不知道如何。

我尝试使用certutil将它们添加到本地证书,但它不起作用。 它弄乱了我的证书数据库。

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

然后

 $ certutil -L -d .mozilla/firefox/kek3dogy.default/ Certificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI 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 ,, 

证书不会出现在Firefox上。 我尝试了几次,甚至删除了配置文件,它在Firefox界面上出现一次,但完全是空的。

无论如何,这仅适用于用户,我想在系统范围内添加它们。 我可以修改一个系统范围的数据库吗? 怎么样?

如果没有我可以修改的系统范围的数据库,我可以依赖于X启动脚本(如/etc/X11/Xsession.d/ ,或者/etc/xdg/autostart/上的xdg自动启动系统调用的脚本) )在会话开始时修改用户配置文件,但我需要一个有效的解决方案。 我现在甚至无法从命令行加载用户配置文件上的证书!

这里的问题是Firefox没有“中心”位置来查找证书。 它只是查看当前的配置文件。 这就是为什么修改/usr/share/ca-certificates或其他类似目录不适用于Firefox。 这是多年来一直要求的; 见问题620373,449498和454036 (可能还有很多其他问题)。

因此,您只需要两种解决方案:修改每个配置文件,或修改Firefox的行为。 我知道这不是你想要的,但没有办法,因为Firefox只关注用户的个人资料。

话虽如此,我选择的解决方案是使用硬链接或符号链接,特别是我会使用硬链接。 虽然我没有足够的信息来判断,但这个解决方案肯定是最容易的,也可能更好。

您需要做的是基本上删除每个配置文件的每个cert8.dbkey3.db文件,并用“最完整”的cert8.dbkey3.db链接替换它们。 如果你使用硬链接,原始的cert8.dbkey3.db将与新的无法区分。

请记住调整权限以满足您的需求。 最有可能的是,您需要chmod a+rw以便每个人都能够添加/删除证书。 如果您只希望某些用户能够添加/删除证书,您可以创建一个组,将两个数据库分配给该组,并仅向该组授予+w权限。

最简单的方法是将证书导入示例firefox-profile,然后将cert8.db复制到要配备证书的用户。

首先手动将证书导入sample-user的firefox配置文件。 然后复制

 /home/${USER}/.mozilla/firefox/${randomalphanum}.default/cert8.db 

进入用户firefox-profiles。 而已。 如果要确保新用户自动获得证书,请将cert8.db复制到:

 /etc/firefox-3.0/profile 

这是一种不覆盖现有证书的替代方法:[Linux系统的bash片段]

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

您可以在libnss3-tools包(debian / ubuntu)中找到certutil。

另请参阅: CA证书的程序化导入

来源:以编程方式将证书安装到Mozilla中

CCK向导Firefox附加组件的一个function是导入CA证书。 我使用此附加组件来创建包含公司CA Cert的自定义附加组件。 然后,我将自定义xpi打包在内部存储库中的.deb中,所有工作站都从中获取更新。

CCK向导

编辑:为了打包Ubuntu的xpi,你需要创建一个包含目录/ usr / lib / firefox-addons / extensions / [addon-name @ servername]的包,并将xpi的全部内容解压缩到这个目录中。 例如,如果您将addon foobarbaz命名为服务器,并将其设置为更新的服务器(如果您要启用该function)是intranet.example.com,则该目录将为foobarbaz@intranet.example.com。 我从不启用自动更新,而是更新回购中的deb。

Firefox在干净安装后工作。 如果删除cert8.db证书数据库,则会在下次Firefox启动时重新生成。 这强烈表明存在CA证书的系统范围默认存储。

Firefox的源代码显示内置CA证书实际上已硬编码到firefox可执行文件中。 它们位于security / nss / lib / ckfw / builtins / certdata.txt中

因此无法在系统范围内安装证书。 请注意,修补源代码可能会带来知识产权问题。

我正在使用“用户环境虚拟化”(UEV)应用程序为我的用户执行此操作,但您可以使用Windows客户端中的登录脚本执行此操作。 我不会发布所有代码来动态查找%APPDATA%\ Mozilla \ Firefox \%PROFILE%路径,但是当您找到它时,可以使用一些基本命令导入脚本。 我基本上是在阅读Firefox profiles.ini文件,以确定Firefox profile / cert8.db的路径。

您可能希望查看使用certutil.exe应用程序。 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil

您可以为自动将受信任证书从中心位置导入系统中所有用户的Firefox的用户运行登录脚本。

这是我的证书导入vb脚本的“核心”:

 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 

我发现大部分时间,默认情况下如果没有配置,则Firefox使用旧版安全数据库(cert8.db,key3.db和secmod.db),这意味着您需要使用不同的命令行将证书注入Firefox使用的正确数据库。 (更多来自certutil的人)

因此,如果您的系统使用默认数据库,则命令应如下所示:(dbm)

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

否则它应该是这样的:(sql)

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

来自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 NSS_DEFAUL 

与流行的看法相反,您可以让Firefox查看系统证书,而不是自己的硬编码集。

为此,您需要使用名为p11-kit的软件包 。 p11-kit为libnssckbi.so提供了一个替代品, libnssckbi.so是包含硬编码证书集的共享库。 而p11-kit版本则从系统证书库中读取证书。

由于Firefox附带了自己版本的libnssckbi.so ,因此您需要对其进行跟踪并替换它而不是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 

接下来,删除~/.pki目录以使Firefox在重新启动Firefox时刷新其证书数据库(使其引入系统证书)。 注意:这将删除商店中的所有现有证书,因此如果您手动添加了自定义证书,则可能需要备份该文件夹,然后重新导入它们。