use SHA-1 as the default digest for the apps/openssl commands
[openssl.git] / apps / req.c
index 5df8f89fcd03f7223e56f2b4b9184400eece5991..f43c477f75b746b6b63cd28581c831ef86cd5fcc 100644 (file)
@@ -187,7 +187,7 @@ int MAIN(int argc, char **argv)
        char *p;
        char *subj = NULL;
        int multirdn = 0;
        char *p;
        char *subj = NULL;
        int multirdn = 0;
-       const EVP_MD *md_alg=NULL,*digest=EVP_md5();
+       const EVP_MD *md_alg=NULL,*digest=EVP_sha1();
        unsigned long chtype = MBSTRING_ASC;
 #ifndef MONOLITH
        char *to_free;
        unsigned long chtype = MBSTRING_ASC;
 #ifndef MONOLITH
        char *to_free;
@@ -567,13 +567,16 @@ bad:
        else
                {
                req_conf=config;
        else
                {
                req_conf=config;
-               if( verbose )
-                       BIO_printf(bio_err,"Using configuration from %s\n",
-                       default_config_file);
+
                if (req_conf == NULL)
                        {
                if (req_conf == NULL)
                        {
-                       BIO_printf(bio_err,"Unable to load config info\n");
+                       BIO_printf(bio_err,"Unable to load config info from %s\n", default_config_file);
+                       if (newreq)
+                               goto end;
                        }
                        }
+               else if( verbose )
+                       BIO_printf(bio_err,"Using configuration from %s\n",
+                       default_config_file);
                }
 
        if (req_conf != NULL)
                }
 
        if (req_conf != NULL)
@@ -748,12 +751,16 @@ bad:
                if (pkey_type == TYPE_RSA)
                        {
                        RSA *rsa = RSA_new();
                if (pkey_type == TYPE_RSA)
                        {
                        RSA *rsa = RSA_new();
-                       if(!rsa || !RSA_generate_key_ex(rsa, newkey, 0x10001, &cb) ||
+                       BIGNUM *bn = BN_new();
+                       if(!bn || !rsa || !BN_set_word(bn, 0x10001) ||
+                                       !RSA_generate_key_ex(rsa, newkey, bn, &cb) ||
                                        !EVP_PKEY_assign_RSA(pkey, rsa))
                                {
                                        !EVP_PKEY_assign_RSA(pkey, rsa))
                                {
+                               if(bn) BN_free(bn);
                                if(rsa) RSA_free(rsa);
                                goto end;
                                }
                                if(rsa) RSA_free(rsa);
                                goto end;
                                }
+                       BN_free(bn);
                        }
                else
 #endif
                        }
                else
 #endif
@@ -919,7 +926,9 @@ loop:
                                }
                        else
                                {
                                }
                        else
                                {
-                               if (!ASN1_INTEGER_set(X509_get_serialNumber(x509ss),0L)) goto end;
+                               if (!rand_serial(NULL,
+                                       X509_get_serialNumber(x509ss)))
+                                               goto end;
                                }
 
                        if (!X509_set_issuer_name(x509ss, X509_REQ_get_subject_name(req))) goto end;
                                }
 
                        if (!X509_set_issuer_name(x509ss, X509_REQ_get_subject_name(req))) goto end;