如何将一个证书自动安装到 Firefox 商店中?

How to install one certificate automated into Firefox store?

我有一个应用程序 (.NET),它通过以下方式自动将证书添加到 Windows 根存储:

X509Store rootStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
rootStore.Open(OpenFlags.ReadWrite);
rootStore.Add(certificate);
rootStore.Close();

Internet Explorer 然后知道这个证书。但是 Firefox 没有,因为它有自己的证书存储。

有没有什么方法可以在不覆盖当前 Firefox 证书的情况下完成此操作(阅读某处以复制 cert8.db 但由于有多个客户,这是不可能的)?

我只是想自动 "add" 一个证书到 Firefox 商店。

提前致谢。

您可以使用 NSS 来管理本地安装的证书。不确定它在 .NET 上的表现如何(如果有的话),但如果环境是可预测的,你可能会求助于 运行 可执行文件。

第一次尝试,效果几乎如我所愿:

文档在这里:https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil

我从以下位置下载了二进制文件: https://www.felixrr.pro/wp-content/uploads/2012/06/nss-3.13.5-nspr-4.9.1-compiled-x86.zip

然后 运行 从提取的 zip 目录中执行以下命令(否则 CMD 将使用 Windows 的 certutil)有效:

// Add certificate to cert8.db (Db will be reloaded on next FF start)
certutil.exe -A -n "SomeName" -t "Cu,p,p" -i "C:\Test\cert.pem" -d "%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\Profilesdrs48sb.default"

// Show all certificates in cert8.db
certutil.exe -L -d "%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\Profilesdrs48sb.default"

重启 FF 后,我可以成功导航到我的 SSL 页面,没有证书错误。

唯一没有用的命令是删除命令,returns 错误 'certutil.exe: could not find certificate named "SomeName": security library: bad database.':

certutil.exe -D -n "SomeName" -d "%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\Profilesdrs48sb.default"