Config code updates.
[openssl.git] / apps / dhparam.c
index bbc64d5eb08d76c0ca3737b128a1ac43f8c8c503..f1664a59b7acc9f7f558980734f7208fe8bafe41 100644 (file)
 #include <openssl/dh.h>
 #include <openssl/x509.h>
 #include <openssl/pem.h>
 #include <openssl/dh.h>
 #include <openssl/x509.h>
 #include <openssl/pem.h>
-#include <openssl/engine.h>
 
 #ifndef OPENSSL_NO_DSA
 #include <openssl/dsa.h>
 
 #ifndef OPENSSL_NO_DSA
 #include <openssl/dsa.h>
@@ -167,6 +166,9 @@ int MAIN(int argc, char **argv)
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
                        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
                        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 
+       if (!load_config(bio_err, NULL))
+               goto end;
+
        infile=NULL;
        outfile=NULL;
        informat=FORMAT_PEM;
        infile=NULL;
        outfile=NULL;
        informat=FORMAT_PEM;
@@ -257,23 +259,7 @@ bad:
 
        ERR_load_crypto_strings();
 
 
        ERR_load_crypto_strings();
 
-       if (engine != NULL)
-               {
-               if((e = ENGINE_by_id(engine)) == NULL)
-                       {
-                       BIO_printf(bio_err,"invalid engine \"%s\"\n",
-                               engine);
-                       goto end;
-                       }
-               if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
-                       {
-                       BIO_printf(bio_err,"can't use that engine\n");
-                       goto end;
-                       }
-               BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
-               /* Free our "structural" reference. */
-               ENGINE_free(e);
-               }
+        e = setup_engine(bio_err, engine, 0);
 
        if (g && !num)
                num = DEFBITS;
 
        if (g && !num)
                num = DEFBITS;
@@ -532,6 +518,7 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
+       apps_shutdown();
        EXIT(ret);
        }
 
        EXIT(ret);
        }