附加一个为X509V3证书添加拓展域的函数
int Add_X509V3_extensions(X509 *cert/*需要添加属性的证书*/,
X509 * root/*根证书(如果属性不涉及根证书,使用本证也可以)*/,
int nid, char *value);
int Add_X509V3_extensions(X509 *cert, X509 * root, int nid, char *value)
{
X509_EXTENSION *ex;
X509V3_CTX ctx;
X509V3_set_ctx(&ctx, root, cert, NULL, NULL, 0);
ex = X509V3_EXT_conf_nid(NULL, &ctx, nid, value);
if (!ex)
return 0;
X509_add_ext(cert, ex, -1);
X509_EXTENSION_free(ex);
return 1;
}
添加CRL分布点
Add_X509V3_extensions(pX509, pX509, NID_crl_distribution_points, "URI:https://123456.com");
添加授权信息访问
Add_X509V3_extensions(pX509, pX509, NID_info_access, "caIssuers;URI:https://123456.com");