添加x509v3扩展会导致Mozilla pkix不信任
Adding x509v3 extension causes Mozilla pkix not to trust
我正在通过NSS/NSPR c++ API添加自签名根证书。
这需要一个x509v3扩展,主题alt名称。但是,添加此扩展或任何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 <31、导致证书被接受
这是一个pkix错误吗?还是我们忽略了什么?
via https://bugzilla.mozilla.org/show_bug.cgi?id=1045973
NSS接受带有v3扩展名的v1/v2证书,mozilla::pkix不接受
解决办法:
X509_set_version(m_x509, 2L);
这个bug是在bugzilla上提交的,所以寻找答案的人可能想要检查这个bug的注释。
相关文章:
- 在C++中嵌入 Mozilla 的 JavaScript 引擎
- 创建 ./config.data 在编译 Mozilla Firefox 时失败
- 我如何调用Mozilla Rhino的Javascript中的C++
- 为什么Mozilla开发者指南更喜欢if(ptr)而不是if(ptr!=nsnull)
- Mozilla C/C++编码风格
- C++ 卡萨布兰卡 vs Mozilla NSPR vs Facebook 愚蠢
- 构建XPCOM Mozilla示例组件
- 添加x509v3扩展会导致Mozilla pkix不信任
- 如何使用c++启动Mozilla Firefox ?
- 用于Mozilla对象的Visual Studio调试器可视化器
- 哪个GUI库用于开发Mozilla Firefox