Initialize num properly.
[openssl.git] / apps / req.c
index 85526581cefed10a9ec539cac8b9a04568a754f9..316163ff786af3790d774574c771350519948a27 100644 (file)
@@ -644,6 +644,11 @@ bad:
                if (inrand)
                        app_RAND_load_files(inrand);
 
+               if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
+                       {
+                       newkey=DEFAULT_KEY_LENGTH;
+                       }
+
                if (keyalg)
                        {
                        genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey,
@@ -652,12 +657,6 @@ bad:
                                goto end;
                        }
        
-               if (newkey <= 0)
-                       {
-                       if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
-                               newkey=DEFAULT_KEY_LENGTH;
-                       }
-
                if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA))
                        {
                        BIO_printf(bio_err,"private key length is too short,\n");
@@ -904,7 +903,7 @@ loop:
 
        if (subj && x509)
                {
-               BIO_printf(bio_err, "Cannot modifiy certificate subject\n");
+               BIO_printf(bio_err, "Cannot modify certificate subject\n");
                goto end;
                }
 
@@ -1159,15 +1158,12 @@ static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int multirdn,
        /* setup version number */
        if (!X509_REQ_set_version(req,0L)) goto err; /* version 1 */
 
-       if (no_prompt) 
+       if (subj)
+               i = build_subject(req, subj, chtype, multirdn);
+       else if (no_prompt) 
                i = auto_info(req, dn_sk, attr_sk, attribs, chtype);
-       else 
-               {
-               if (subj)
-                       i = build_subject(req, subj, chtype, multirdn);
-               else
-                       i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs, chtype);
-               }
+       else
+               i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs, chtype);
        if(!i) goto err;
 
        if (!X509_REQ_set_pubkey(req,pkey)) goto err;
@@ -1649,6 +1645,8 @@ static EVP_PKEY_CTX *set_keygen_ctx(BIO *err, const char *gstr, int *pkey_type,
                                keylen = atol(p + 1);
                                *pkeylen = keylen;
                                }
+                       else
+                               keylen = *pkeylen;
                        }
                else if (p)
                        paramfile = p + 1;