【问题标题】:Adding x509v3 extension causes Mozilla pkix not to trust添加 x509v3 扩展会导致 Mozilla pkix 不信任
【发布时间】: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


    【解决方案1】:

    通过https://bugzilla.mozilla.org/show_bug.cgi?id=1045973

    NSS 接受带有 v3 扩展的 v1/v2 证书,mozilla::pkix 不接受

    修复:

    X509_set_version(m_x509, 2L);
    

    【讨论】:

      【解决方案2】:

      这个错误是filed at bugzilla,所以寻找答案的人可能想检查这个错误的 cmets。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-03-24
        • 2015-12-16
        • 1970-01-01
        • 2011-03-22
        • 1970-01-01
        • 1970-01-01
        • 2020-06-29
        相关资源
        最近更新 更多