Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl30/crypto/x509/v3_conf.c
Line
Count
Source
1
/*
2
 * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
/* extension creation utilities */
11
12
#include <stdio.h>
13
#include "crypto/ctype.h"
14
#include "internal/cryptlib.h"
15
#include <openssl/conf.h>
16
#include <openssl/x509.h>
17
#include "crypto/x509.h"
18
#include <openssl/x509v3.h>
19
20
static int v3_check_critical(const char **value);
21
static int v3_check_generic(const char **value);
22
static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
23
    int crit, const char *value);
24
static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value,
25
    int crit, int type,
26
    X509V3_CTX *ctx);
27
static char *conf_lhash_get_string(void *db, const char *section, const char *value);
28
static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, const char *section);
29
static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
30
    int ext_nid, int crit, void *ext_struc);
31
static unsigned char *generic_asn1(const char *value, X509V3_CTX *ctx,
32
    long *ext_len);
33
34
static X509_EXTENSION *X509V3_EXT_nconf_int(CONF *conf, X509V3_CTX *ctx,
35
    const char *section,
36
    const char *name, const char *value)
37
0
{
38
0
    int crit;
39
0
    int ext_type;
40
0
    X509_EXTENSION *ret;
41
42
0
    crit = v3_check_critical(&value);
43
0
    if ((ext_type = v3_check_generic(&value)))
44
0
        return v3_generic_extension(name, value, crit, ext_type, ctx);
45
0
    ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value);
46
0
    if (!ret) {
47
0
        if (section != NULL)
48
0
            ERR_raise_data(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION,
49
0
                "section=%s, name=%s, value=%s",
50
0
                section, name, value);
51
0
        else
52
0
            ERR_raise_data(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION,
53
0
                "name=%s, value=%s", name, value);
54
0
    }
55
0
    return ret;
56
0
}
57
58
X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
59
    const char *value)
60
0
{
61
0
    return X509V3_EXT_nconf_int(conf, ctx, NULL, name, value);
62
0
}
63
64
X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
65
    const char *value)
66
0
{
67
0
    int crit;
68
0
    int ext_type;
69
70
0
    crit = v3_check_critical(&value);
71
0
    if ((ext_type = v3_check_generic(&value)))
72
0
        return v3_generic_extension(OBJ_nid2sn(ext_nid),
73
0
            value, crit, ext_type, ctx);
74
0
    return do_ext_nconf(conf, ctx, ext_nid, crit, value);
75
0
}
76
77
/* CONF *conf:  Config file    */
78
/* char *value:  Value    */
79
static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
80
    int crit, const char *value)
81
0
{
82
0
    const X509V3_EXT_METHOD *method;
83
0
    X509_EXTENSION *ext;
84
0
    STACK_OF(CONF_VALUE) *nval;
85
0
    void *ext_struc;
86
87
0
    if (ext_nid == NID_undef) {
88
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_UNKNOWN_EXTENSION_NAME);
89
0
        return NULL;
90
0
    }
91
0
    if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) {
92
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_UNKNOWN_EXTENSION);
93
0
        return NULL;
94
0
    }
95
    /* Now get internal extension representation based on type */
96
0
    if (method->v2i) {
97
0
        if (*value == '@')
98
0
            nval = NCONF_get_section(conf, value + 1);
99
0
        else
100
0
            nval = X509V3_parse_list(value);
101
0
        if (nval == NULL || sk_CONF_VALUE_num(nval) <= 0) {
102
0
            ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_EXTENSION_STRING,
103
0
                "name=%s,section=%s", OBJ_nid2sn(ext_nid), value);
104
0
            if (*value != '@')
105
0
                sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
106
0
            return NULL;
107
0
        }
108
0
        ext_struc = method->v2i(method, ctx, nval);
109
0
        if (*value != '@')
110
0
            sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
111
0
        if (!ext_struc)
112
0
            return NULL;
113
0
    } else if (method->s2i) {
114
0
        if ((ext_struc = method->s2i(method, ctx, value)) == NULL)
115
0
            return NULL;
116
0
    } else if (method->r2i) {
117
0
        if (!ctx->db || !ctx->db_meth) {
118
0
            ERR_raise(ERR_LIB_X509V3, X509V3_R_NO_CONFIG_DATABASE);
119
0
            return NULL;
120
0
        }
121
0
        if ((ext_struc = method->r2i(method, ctx, value)) == NULL)
122
0
            return NULL;
123
0
    } else {
124
0
        ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED,
125
0
            "name=%s", OBJ_nid2sn(ext_nid));
126
0
        return NULL;
127
0
    }
128
129
0
    ext = do_ext_i2d(method, ext_nid, crit, ext_struc);
130
0
    if (method->it)
131
0
        ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it));
132
0
    else
133
0
        method->ext_free(ext_struc);
134
0
    return ext;
135
0
}
136
137
static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
138
    int ext_nid, int crit, void *ext_struc)
139
0
{
140
0
    unsigned char *ext_der = NULL;
141
0
    int ext_len;
142
0
    ASN1_OCTET_STRING *ext_oct = NULL;
143
0
    X509_EXTENSION *ext;
144
145
    /* Convert internal representation to DER */
146
0
    if (method->it) {
147
0
        ext_der = NULL;
148
0
        ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it));
149
0
        if (ext_len < 0)
150
0
            goto merr;
151
0
    } else {
152
0
        unsigned char *p;
153
154
0
        ext_len = method->i2d(ext_struc, NULL);
155
0
        if (ext_len <= 0)
156
0
            goto merr;
157
0
        if ((ext_der = OPENSSL_malloc(ext_len)) == NULL)
158
0
            goto merr;
159
0
        p = ext_der;
160
0
        method->i2d(ext_struc, &p);
161
0
    }
162
0
    if ((ext_oct = ASN1_OCTET_STRING_new()) == NULL)
163
0
        goto merr;
164
0
    ext_oct->data = ext_der;
165
0
    ext_der = NULL;
166
0
    ext_oct->length = ext_len;
167
168
0
    ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
169
0
    if (!ext)
170
0
        goto merr;
171
0
    ASN1_OCTET_STRING_free(ext_oct);
172
173
0
    return ext;
174
175
0
merr:
176
0
    ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE);
177
0
    OPENSSL_free(ext_der);
178
0
    ASN1_OCTET_STRING_free(ext_oct);
179
0
    return NULL;
180
0
}
181
182
/* Given an internal structure, nid and critical flag create an extension */
183
184
X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc)
185
0
{
186
0
    const X509V3_EXT_METHOD *method;
187
188
0
    if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) {
189
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_UNKNOWN_EXTENSION);
190
0
        return NULL;
191
0
    }
192
0
    return do_ext_i2d(method, ext_nid, crit, ext_struc);
193
0
}
194
195
/* Check the extension string for critical flag */
196
static int v3_check_critical(const char **value)
197
0
{
198
0
    const char *p = *value;
199
200
0
    if ((strlen(p) < 9) || strncmp(p, "critical,", 9))
201
0
        return 0;
202
0
    p += 9;
203
0
    while (ossl_isspace(*p))
204
0
        p++;
205
0
    *value = p;
206
0
    return 1;
207
0
}
208
209
/* Check extension string for generic extension and return the type */
210
static int v3_check_generic(const char **value)
211
0
{
212
0
    int gen_type = 0;
213
0
    const char *p = *value;
214
215
0
    if ((strlen(p) >= 4) && strncmp(p, "DER:", 4) == 0) {
216
0
        p += 4;
217
0
        gen_type = 1;
218
0
    } else if ((strlen(p) >= 5) && strncmp(p, "ASN1:", 5) == 0) {
219
0
        p += 5;
220
0
        gen_type = 2;
221
0
    } else
222
0
        return 0;
223
224
0
    while (ossl_isspace(*p))
225
0
        p++;
226
0
    *value = p;
227
0
    return gen_type;
228
0
}
229
230
/* Create a generic extension: for now just handle DER type */
231
static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value,
232
    int crit, int gen_type,
233
    X509V3_CTX *ctx)
234
0
{
235
0
    unsigned char *ext_der = NULL;
236
0
    long ext_len = 0;
237
0
    ASN1_OBJECT *obj = NULL;
238
0
    ASN1_OCTET_STRING *oct = NULL;
239
0
    X509_EXTENSION *extension = NULL;
240
241
0
    if ((obj = OBJ_txt2obj(ext, 0)) == NULL) {
242
0
        ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_NAME_ERROR,
243
0
            "name=%s", ext);
244
0
        goto err;
245
0
    }
246
247
0
    if (gen_type == 1)
248
0
        ext_der = OPENSSL_hexstr2buf(value, &ext_len);
249
0
    else if (gen_type == 2)
250
0
        ext_der = generic_asn1(value, ctx, &ext_len);
251
252
0
    if (ext_der == NULL) {
253
0
        ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_VALUE_ERROR,
254
0
            "value=%s", value);
255
0
        goto err;
256
0
    }
257
258
0
    if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
259
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE);
260
0
        goto err;
261
0
    }
262
263
0
    oct->data = ext_der;
264
0
    oct->length = ext_len;
265
0
    ext_der = NULL;
266
267
0
    extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct);
268
269
0
err:
270
0
    ASN1_OBJECT_free(obj);
271
0
    ASN1_OCTET_STRING_free(oct);
272
0
    OPENSSL_free(ext_der);
273
0
    return extension;
274
0
}
275
276
static unsigned char *generic_asn1(const char *value, X509V3_CTX *ctx,
277
    long *ext_len)
278
0
{
279
0
    ASN1_TYPE *typ;
280
0
    unsigned char *ext_der = NULL;
281
282
0
    typ = ASN1_generate_v3(value, ctx);
283
0
    if (typ == NULL)
284
0
        return NULL;
285
0
    *ext_len = i2d_ASN1_TYPE(typ, &ext_der);
286
0
    ASN1_TYPE_free(typ);
287
0
    return ext_der;
288
0
}
289
290
static void delete_ext(STACK_OF(X509_EXTENSION) *sk, X509_EXTENSION *dext)
291
0
{
292
0
    int idx;
293
0
    ASN1_OBJECT *obj;
294
295
0
    obj = X509_EXTENSION_get_object(dext);
296
0
    while ((idx = X509v3_get_ext_by_OBJ(sk, obj, -1)) >= 0)
297
0
        X509_EXTENSION_free(X509v3_delete_ext(sk, idx));
298
0
}
299
300
/*
301
 * This is the main function: add a bunch of extensions based on a config
302
 * file section to an extension STACK. Just check in case sk == NULL.
303
 * Note that on error new elements may have been added to *sk if sk != NULL.
304
 */
305
int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,
306
    STACK_OF(X509_EXTENSION) **sk)
307
0
{
308
0
    X509_EXTENSION *ext;
309
0
    STACK_OF(CONF_VALUE) *nval;
310
0
    CONF_VALUE *val;
311
0
    int i;
312
313
0
    if ((nval = NCONF_get_section(conf, section)) == NULL)
314
0
        return 0;
315
0
    for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
316
0
        val = sk_CONF_VALUE_value(nval, i);
317
0
        if ((ext = X509V3_EXT_nconf_int(conf, ctx, val->section,
318
0
                 val->name, val->value))
319
0
            == NULL)
320
0
            return 0;
321
0
        if (sk != NULL) {
322
0
            if (ctx->flags == X509V3_CTX_REPLACE)
323
0
                delete_ext(*sk, ext);
324
0
            if (X509v3_add_ext(sk, ext, -1) == NULL) {
325
0
                X509_EXTENSION_free(ext);
326
0
                return 0;
327
0
            }
328
0
        }
329
0
        X509_EXTENSION_free(ext);
330
0
    }
331
0
    return 1;
332
0
}
333
334
/*
335
 * Add extensions to a certificate. Just check in case cert == NULL.
336
 * Note that on error new elements may remain added to cert if cert != NULL.
337
 */
338
int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
339
    X509 *cert)
340
0
{
341
0
    STACK_OF(X509_EXTENSION) **sk = NULL;
342
0
    if (cert != NULL)
343
0
        sk = &cert->cert_info.extensions;
344
0
    return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
345
0
}
346
347
/*
348
 * Add extensions to a CRL. Just check in case crl == NULL.
349
 * Note that on error new elements may remain added to crl if crl != NULL.
350
 */
351
int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
352
    X509_CRL *crl)
353
0
{
354
0
    STACK_OF(X509_EXTENSION) **sk = NULL;
355
0
    if (crl != NULL)
356
0
        sk = &crl->crl.extensions;
357
0
    return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
358
0
}
359
360
/*
361
 * Add extensions to certificate request. Just check in case req is NULL.
362
 * Note that on error new elements may remain added to req if req != NULL.
363
 */
364
int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
365
    X509_REQ *req)
366
0
{
367
0
    STACK_OF(X509_EXTENSION) *exts = NULL;
368
0
    int ret = X509V3_EXT_add_nconf_sk(conf, ctx, section, &exts);
369
370
0
    if (ret && req != NULL && exts != NULL)
371
0
        ret = X509_REQ_add_extensions(req, exts);
372
0
    sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
373
0
    return ret;
374
0
}
375
376
/* Config database functions */
377
378
char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section)
379
0
{
380
0
    if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_string) {
381
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_OPERATION_NOT_DEFINED);
382
0
        return NULL;
383
0
    }
384
0
    if (ctx->db_meth->get_string)
385
0
        return ctx->db_meth->get_string(ctx->db, name, section);
386
0
    return NULL;
387
0
}
388
389
STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section)
390
0
{
391
0
    if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section) {
392
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_OPERATION_NOT_DEFINED);
393
0
        return NULL;
394
0
    }
395
0
    if (ctx->db_meth->get_section)
396
0
        return ctx->db_meth->get_section(ctx->db, section);
397
0
    return NULL;
398
0
}
399
400
void X509V3_string_free(X509V3_CTX *ctx, char *str)
401
0
{
402
0
    if (!str)
403
0
        return;
404
0
    if (ctx->db_meth->free_string)
405
0
        ctx->db_meth->free_string(ctx->db, str);
406
0
}
407
408
void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section)
409
0
{
410
0
    if (!section)
411
0
        return;
412
0
    if (ctx->db_meth->free_section)
413
0
        ctx->db_meth->free_section(ctx->db, section);
414
0
}
415
416
static char *nconf_get_string(void *db, const char *section, const char *value)
417
0
{
418
0
    return NCONF_get_string(db, section, value);
419
0
}
420
421
static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, const char *section)
422
0
{
423
0
    return NCONF_get_section(db, section);
424
0
}
425
426
static X509V3_CONF_METHOD nconf_method = {
427
    nconf_get_string,
428
    nconf_get_section,
429
    NULL,
430
    NULL
431
};
432
433
void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf)
434
0
{
435
0
    if (ctx == NULL) {
436
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_NULL_PARAMETER);
437
0
        return;
438
0
    }
439
0
    ctx->db_meth = &nconf_method;
440
0
    ctx->db = conf;
441
0
}
442
443
void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
444
    X509_CRL *crl, int flags)
445
0
{
446
0
    if (ctx == NULL) {
447
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_NULL_PARAMETER);
448
0
        return;
449
0
    }
450
0
    ctx->flags = flags;
451
0
    ctx->issuer_cert = issuer;
452
0
    ctx->subject_cert = subj;
453
0
    ctx->subject_req = req;
454
0
    ctx->crl = crl;
455
0
    ctx->db_meth = NULL;
456
0
    ctx->db = NULL;
457
0
    ctx->issuer_pkey = NULL;
458
0
}
459
460
/* For API backward compatibility, this is separate from X509V3_set_ctx() */
461
int X509V3_set_issuer_pkey(X509V3_CTX *ctx, EVP_PKEY *pkey)
462
0
{
463
0
    if (ctx == NULL) {
464
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_NULL_PARAMETER);
465
0
        return 0;
466
0
    }
467
0
    if (ctx->subject_cert == NULL && pkey != NULL) {
468
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_INVALID_ARGUMENT);
469
0
        return 0;
470
0
    }
471
0
    ctx->issuer_pkey = pkey;
472
0
    return 1;
473
0
}
474
475
/* Old conf compatibility functions */
476
477
X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
478
    const char *name, const char *value)
479
0
{
480
0
    CONF *ctmp;
481
0
    X509_EXTENSION *ret;
482
483
0
    if ((ctmp = NCONF_new(NULL)) == NULL)
484
0
        return NULL;
485
0
    CONF_set_nconf(ctmp, conf);
486
0
    ret = X509V3_EXT_nconf(ctmp, ctx, name, value);
487
0
    CONF_set_nconf(ctmp, NULL);
488
0
    NCONF_free(ctmp);
489
0
    return ret;
490
0
}
491
492
X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,
493
    X509V3_CTX *ctx, int ext_nid, const char *value)
494
0
{
495
0
    CONF *ctmp;
496
0
    X509_EXTENSION *ret;
497
498
0
    if ((ctmp = NCONF_new(NULL)) == NULL)
499
0
        return NULL;
500
0
    CONF_set_nconf(ctmp, conf);
501
0
    ret = X509V3_EXT_nconf_nid(ctmp, ctx, ext_nid, value);
502
0
    CONF_set_nconf(ctmp, NULL);
503
0
    NCONF_free(ctmp);
504
0
    return ret;
505
0
}
506
507
static char *conf_lhash_get_string(void *db, const char *section, const char *value)
508
0
{
509
0
    return CONF_get_string(db, section, value);
510
0
}
511
512
static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, const char *section)
513
0
{
514
0
    return CONF_get_section(db, section);
515
0
}
516
517
static X509V3_CONF_METHOD conf_lhash_method = {
518
    conf_lhash_get_string,
519
    conf_lhash_get_section,
520
    NULL,
521
    NULL
522
};
523
524
void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash)
525
0
{
526
0
    if (ctx == NULL) {
527
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_NULL_PARAMETER);
528
0
        return;
529
0
    }
530
0
    ctx->db_meth = &conf_lhash_method;
531
0
    ctx->db = lhash;
532
0
}
533
534
int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
535
    const char *section, X509 *cert)
536
0
{
537
0
    CONF *ctmp;
538
0
    int ret;
539
540
0
    if ((ctmp = NCONF_new(NULL)) == NULL)
541
0
        return 0;
542
0
    CONF_set_nconf(ctmp, conf);
543
0
    ret = X509V3_EXT_add_nconf(ctmp, ctx, section, cert);
544
0
    CONF_set_nconf(ctmp, NULL);
545
0
    NCONF_free(ctmp);
546
0
    return ret;
547
0
}
548
549
/* Same as above but for a CRL */
550
551
int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
552
    const char *section, X509_CRL *crl)
553
0
{
554
0
    CONF *ctmp;
555
0
    int ret;
556
557
0
    if ((ctmp = NCONF_new(NULL)) == NULL)
558
0
        return 0;
559
0
    CONF_set_nconf(ctmp, conf);
560
0
    ret = X509V3_EXT_CRL_add_nconf(ctmp, ctx, section, crl);
561
0
    CONF_set_nconf(ctmp, NULL);
562
0
    NCONF_free(ctmp);
563
0
    return ret;
564
0
}
565
566
/* Add extensions to certificate request */
567
568
int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
569
    const char *section, X509_REQ *req)
570
0
{
571
0
    CONF *ctmp;
572
0
    int ret;
573
574
0
    if ((ctmp = NCONF_new(NULL)) == NULL)
575
0
        return 0;
576
0
    CONF_set_nconf(ctmp, conf);
577
0
    ret = X509V3_EXT_REQ_add_nconf(ctmp, ctx, section, req);
578
    CONF_set_nconf(ctmp, NULL);
579
0
    NCONF_free(ctmp);
580
0
    return ret;
581
0
}