从命令行将 PKCS#12 证书安装到 Firefox 中

从命令行将 PKCS#12 证书安装到 Firefox 中

我正在尝试使用 certutil 添加客户端证书到 Firefox 数据库:此证书的目的是与服务器进行身份验证 - 服务器要求提供凭证,此证书包含凭证。

certutil -A -n "My Certificate" -d /myfirefoxprofile/ -t "CT,," -a -i /mycertificate.pfx 

然而这给了我错误:

certutil: could not obtain certificate from file: security library: improperly formatted DER-encoded message.

我是不是做了一些明显错误的事情?

这是在 ubuntu 10.10 上

答案1

看起来您需要将 PFX 转换为 PEM...使用 openssl 开关的方向如下:http://support.citrix.com/article/CTX106028

说清楚一点,显然我有点困惑:

从 pfx 转换为 pem,然后使用新文件重新运行导入命令(编辑:和下面修改后的选项)。在我看来,firefox 证书导入正在阻塞 pfx 文件类型(编辑:并且未指定适当的导入选项)。链接到的方向不是用于 firefox 导入,而是用于证书转换。

问题编辑后进行附加编辑:

-t 需要 u 选项才能用作客户端证书。-u 标志需要 C 选项...certutil 标志记录在此处:http://www.mozilla.org/projects/security/pki/nss/tools/certutil.html

你可能还想看看这里:http://www.phocean.net/2008/11/16/how-to-stop-firefox-from-prompting-for-the-client-certificate.html
浏览器可能会提示使用证书

certutil -A -n “我的证书” -d /myfirefoxprofile/ -t “CTu,,” -u “c” -a -i /mycertificate.pem

应该这样做

答案2

以下是我将客户端证书导入空的 Firefox 配置文件的方法:

# convert pem and key file into a pkcs12
openssl pkcs12 -export -in /path/my-cert.pem -inkey /path/my-cert.key -out /tmp/my-cert.p12 

# create empty directory
mkdir /tmp/empty_profile

# populate dir with certificate databases
certutil -N -d sql:/tmp/empty_profile

# import p12 file into database
pk12util -d sql:/tmp/empty_profile -i /tmp/mycert.p12 -n my-cert-nickname 

相关内容