无法在c ++中使用openssl API添加证书策略扩展

时间:2014-01-28 15:24:49

标签: c++ openssl

我尝试使用以下语法:

  • add_ext(x509OutCertificate, NID_certificate_policies, "Policy: 2.16.840.1.113733.1.7.54 ,CPS: https://www.verisign.com/cps");

  • add_ext(x509OutCertificate, NID_certificate_policies, "2.16.840.1.113733.1.7.54,https://www.verisign.com/cps");

&安培;更多组合。

但无法在证书中添加此扩展程序。有什么问题的线索?

提前致谢

1 个答案:

答案 0 :(得分:0)

这是一个评论,但评论没有空格。

$ grep -R NID_certificate_policies *crypto/objects/obj_dat.h:   NID_certificate_policies,3,&(lvalues[512]),0},
crypto/objects/objects.h:#define NID_certificate_policies   89
crypto/objects/obj_mac.h:#define NID_certificate_policies       89
crypto/x509v3/v3_cpols.c:NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES),
crypto/x509v3/pcy_cache.c:  ext_cpols = X509_get_ext_d2i(x, NID_certificate_policies, &i, NULL);
crypto/x509v3/v3_purp.c:        NID_certificate_policies, /* 89 */

v3_cpols.c,有一个不祥的警告:

/* Certificate policies extension support: this one is a bit complex... */

以下是它的声明:

const X509V3_EXT_METHOD v3_cpols = {
  NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES),
  0,0,0,0,
  0,0,
  0,0,
  (X509V3_EXT_I2R)i2r_certpol,
  (X509V3_EXT_R2I)r2i_certpol,
  NULL
};

ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = 
    ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO)
ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES)

IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
然后在v3_cpol

中使用

ext_dat.h

static const X509V3_EXT_METHOD *standard_exts[] = {
  &v3_nscert,
  &v3_ns_ia5_list[0],
  &v3_ns_ia5_list[1],
  &v3_ns_ia5_list[2],
  &v3_ns_ia5_list[3],
  &v3_ns_ia5_list[4],
  &v3_ns_ia5_list[5],
  &v3_ns_ia5_list[6],
  ...
  &v3_cpols,
  ...
};

似乎没有文档或明确用法。我在OpenSSL上的这两本书缺乏对它的处理。看起来你在泥泞的水域。

也许OpenSSL user's list的人可以提供帮助。我建议这是因为列表中的一些人可能会回答它(SH,DT,VD等),但我还没有在Stack Overflow的网站上看到它们。