69 static int v3_check_critical(
char **value);
70 static int v3_check_generic(
char **value);
73 static char *conf_lhash_get_string(
void *db,
char *section,
char *value);
76 int crit,
void *ext_struc);
77 static unsigned char *generic_asn1(
char *value,
X509V3_CTX *ctx,
long *ext_len);
87 crit = v3_check_critical(&value);
88 if ((ext_type = v3_check_generic(&value)))
89 return v3_generic_extension(name, value, crit, ext_type, ctx);
90 ret = do_ext_nconf(conf, ctx,
OBJ_sn2nid(name), crit, value);
106 crit = v3_check_critical(&value);
107 if ((ext_type = v3_check_generic(&value)))
108 return v3_generic_extension(
OBJ_nid2sn(ext_nid),
109 value, crit, ext_type, ctx);
110 return do_ext_nconf(conf, ctx, ext_nid, crit, value);
116 int crit,
char *value)
135 if(*value ==
'@') nval = NCONF_get_section(conf, value + 1);
136 else nval = X509V3_parse_list(value);
143 ext_struc = method->
v2i(method, ctx, nval);
146 if(!ext_struc)
return NULL;
150 if(!(ext_struc = method->
s2i(method, ctx, value)))
return NULL;
159 if(!(ext_struc = method->
r2i(method, ctx, value)))
return NULL;
168 ext = do_ext_i2d(method, ext_nid, crit, ext_struc);
176 int crit,
void *ext_struc)
178 unsigned char *ext_der;
187 if (ext_len < 0)
goto merr;
192 ext_len = method->
i2d(ext_struc, NULL);
195 method->
i2d(ext_struc, &p);
198 ext_oct->
data = ext_der;
199 ext_oct->
length = ext_len;
222 return do_ext_i2d(method, ext_nid, crit, ext_struc);
226 static int v3_check_critical(
char **value)
229 if ((strlen(p) < 9) || strncmp(p,
"critical,", 9))
return 0;
231 while(isspace((
unsigned char)*p)) p++;
237 static int v3_check_generic(
char **value)
241 if ((strlen(p) >= 4) && !strncmp(p,
"DER:", 4))
246 else if ((strlen(p) >= 5) && !strncmp(p,
"ASN1:", 5))
254 while (isspace((
unsigned char)*p)) p++;
260 static X509_EXTENSION *v3_generic_extension(
const char *ext,
char *value,
261 int crit,
int gen_type,
264 unsigned char *ext_der=NULL;
278 else if (gen_type == 2)
279 ext_der = generic_asn1(value, ctx, &ext_len);
308 static unsigned char *generic_asn1(
char *value,
X509V3_CTX *ctx,
long *ext_len)
311 unsigned char *ext_der = NULL;
315 *ext_len = i2d_ASN1_TYPE(typ, &ext_der);
332 if (!(nval = NCONF_get_section(conf, section)))
return 0;
336 if (!(ext = X509V3_EXT_nconf(conf, ctx, val->
name, val->
value)))
338 if (sk) X509v3_add_ext(sk, ext, -1);
339 X509_EXTENSION_free(ext);
362 sk = &crl->
crl->extensions;
405 return ctx->
db_meth->get_section(ctx->
db, section);
418 if (!section)
return;
423 static char *nconf_get_string(
void *db,
char *section,
char *value)
430 return NCONF_get_section(db, section);
459 char *name,
char *value)
463 return X509V3_EXT_nconf(&ctmp, ctx, name, value);
469 int ext_nid,
char *value)
476 static char *conf_lhash_get_string(
void *db,
char *section,
char *value)
483 return CONF_get_section(db, section);
487 conf_lhash_get_string,
488 conf_lhash_get_section,
495 ctx->
db_meth = &conf_lhash_method;
500 char *section,
X509 *cert)