Config code updates.
[openssl.git] / apps / dh.c
index 229ba2f63a2d5797ea37d595de32655c1423a47c..27c3dc8df22cdc8e86d5d8a80ccaaace72bff20d 100644 (file)
--- a/apps/dh.c
+++ b/apps/dh.c
@@ -57,7 +57,7 @@
  * [including the GNU Public Licence.]
  */
 
-#ifndef NO_DH
+#ifndef OPENSSL_NO_DH
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -69,7 +69,6 @@
 #include <openssl/dh.h>
 #include <openssl/x509.h>
 #include <openssl/pem.h>
-#include <openssl/engine.h>
 
 #undef PROG
 #define PROG   dh_main
@@ -101,6 +100,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 (!load_config(bio_err, NULL))
+               goto end;
+
        engine=NULL;
        infile=NULL;
        outfile=NULL;
@@ -174,23 +176,7 @@ bad:
 
        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);
 
        in=BIO_new(BIO_s_file());
        out=BIO_new(BIO_s_file());
@@ -213,7 +199,7 @@ bad:
        if (outfile == NULL)
                {
                BIO_set_fp(out,stdout,BIO_NOCLOSE);
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
                {
                BIO *tmpbio = BIO_new(BIO_f_linebuffer());
                out = BIO_push(tmpbio, out);
@@ -346,6 +332,7 @@ end:
        if (in != NULL) BIO_free(in);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
+       apps_shutdown();
        EXIT(ret);
        }
 #endif