summaryrefslogtreecommitdiffstats
path: root/apps/req.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-08-25 16:59:26 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-08-25 16:59:26 +0000
commitc79b16e11d70488f4de0e766d78f6a5ce77d99af (patch)
treefad4e8d20108152d2d0a12229e4d92ad560a0c17 /apps/req.c
parent43ca6c02dc702b8fff20205ec62ec03eed77eb1b (diff)
Allow extensions to be added to certificate requests, update the sample
config file (change RAW to DER).
Diffstat (limited to 'apps/req.c')
-rw-r--r--apps/req.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/req.c b/apps/req.c
index 463ac156ea..fa8f7339f3 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -82,6 +82,7 @@
#define DISTINGUISHED_NAME "distinguished_name"
#define ATTRIBUTES "attributes"
#define V3_EXTENSIONS "x509_extensions"
+#define REQ_EXTENSIONS "req_extensions"
#define DEFAULT_KEY_LENGTH 512
#define MIN_KEY_LENGTH 384
@@ -142,6 +143,7 @@ int MAIN(int argc, char **argv)
int nodes=0,kludge=0;
char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL;
char *extensions = NULL;
+ char *req_exts = NULL;
EVP_CIPHER *cipher=NULL;
int modulus=0;
char *p;
@@ -438,6 +440,20 @@ bad:
}
}
+ req_exts = CONF_get_string(req_conf, SECTION, REQ_EXTENSIONS);
+ if(req_exts) {
+ /* Check syntax of file */
+ X509V3_CTX ctx;
+ X509V3_set_ctx_test(&ctx);
+ X509V3_set_conf_lhash(&ctx, req_conf);
+ if(!X509V3_EXT_add_conf(req_conf, &ctx, req_exts, NULL)) {
+ BIO_printf(bio_err,
+ "Error Loading request extension section %s\n",
+ req_exts);
+ goto end;
+ }
+ }
+
in=BIO_new(BIO_s_file());
out=BIO_new(BIO_s_file());
if ((in == NULL) || (out == NULL))
@@ -677,6 +693,22 @@ loop:
}
else
{
+ X509V3_CTX ext_ctx;
+
+ /* Set up V3 context struct */
+
+ X509V3_set_ctx(&ext_ctx, NULL, NULL, req, NULL, 0);
+ X509V3_set_conf_lhash(&ext_ctx, req_conf);
+
+ /* Add extensions */
+ if(req_exts && !X509V3_EXT_REQ_add_conf(req_conf,
+ &ext_ctx, req_exts, req))
+ {
+ BIO_printf(bio_err,
+ "Error Loading extension section %s\n",
+ req_exts);
+ goto end;
+ }
if (!(i=X509_REQ_sign(req,pkey,digest)))
goto end;
}