windows - 为什么 firefox 只信任 certutil 安装的证书?

windows - Why firefox only trust certificate which certutil install?

我最近在研究 windows 中的证书。

我尝试了两种不同的方式来安装证书:
1.使用certutil命令安装。例如:certutil -addstore -f "ROOT" rootCA.pem
2.使用微软api安装。

certStore = CertOpenSystemStore(NULL, "ROOT")
CertAddEncodedCertificateToStore(
    certStore,
    X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
    rootCACert,
    len(rootCACert),
    CERT_STORE_ADD_REPLACE_EXISTING,
    NULL
)

安装后,我用certmgr.msc检查是否成功。
而 firefox 的 security.enterprise_roots.enabled 设置为 True.

但是我发现了一个奇怪的情况
Firefox 只信任 certutil 安装的证书。

谁能告诉我为什么?

提前致谢!

根据 Mozilla Wiki 版本存在差异:

As of version 49, ... Firefox will inspect the HKLM\SOFTWARE\Microsoft\SystemCertificates registry location (corresponding to the API flag CERT_SYSTEM_STORE_LOCAL_MACHINE)

As of version 52, Firefox will also search the registry locations HKLM\SOFTWARE\Policies\Microsoft\SystemCertificates\Root\Certificates and HKLM\SOFTWARE\Microsoft\EnterpriseCertificates\Root\Certificates (corresponding to the API flags CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY and CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, respectively).

所以很高兴知道您使用的是什么版本。

回答您的问题:由于搜索到的商店的标志在 wiki 中被命名,因此您似乎在 API 解决方案中使用了错误的商店。看看函数 CertOpenStore 而不是 CertOpenSystemStore。这允许通过例如CERT_SYSTEM_STORE_LOCAL_MACHINE 作为 dwFlags 打开商店 Mozilla 搜索。