【发布时间】:2014-07-30 03:07:33
【问题描述】:
我正在通过 NSS/NSPR C++ API 添加自签名根证书。
这需要一个 x509v3 扩展名,即主题替代名称。但是,添加此扩展或任何 x509v3 扩展会导致 firefox 失败并显示 Error code: sec_error_extension_value_invalid。
// Add subjectAltName x509v3 extension containing our localhost IPv4
// address of 127.0.0.1. The subjectAltName entry takes precedence over
// the CommonName (CN) entry, thus we are allowed to have a more
// descriptive name there. In addition, this is needed by Safari on Mac in
// order to properly trust the certificate.
X509V3_CTX ctx;
X509V3_set_ctx_nodb(&ctx);
X509V3_set_ctx(&ctx, m_x509, m_x509, nullptr, nullptr, 0);
// Removing this line causes the cert to be accepted by firefox:
X509_EXTENSION* ext = X509V3_EXT_conf_nid(nullptr, &ctx, NID_subject_alt_name, (char*)"DNS:127.0.0.1,IP:127.0.0.1");
if (ext) {
X509_add_ext(m_x509, ext , -1);
X509_EXTENSION_free(ext);
}
// Sign the certificate
X509_sign(m_x509, m_key->m_pkey, EVP_sha1());
这似乎是一个 pkix 错误,因为在 about:config 中设置 use_mozillapkix_verification = false,或者使用 ff
这是一个 pkix 错误吗?还是这里忽略了什么?
【问题讨论】:
标签: c++ firefox ssl certificate mozilla