From branch OpenSSL_0_9_8-stable: Allow soft-loading engines.
[openssl.git] / crypto / engine / eng_cnf.c
index 7bc30602e92a26769eee2b6a73b5fa52e1283704..afd6b6f8c7f991c4396db1790159f4da3e3b219b 100644 (file)
@@ -98,6 +98,8 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
        CONF_VALUE *ecmd;
        char *ctrlname, *ctrlvalue;
        ENGINE *e = NULL;
+       int soft = 0;
+
        name = skip_dot(name);
 #ifdef ENGINE_CONF_DEBUG
        fprintf(stderr, "Configuring engine %s\n", name);
@@ -125,6 +127,8 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
                /* Override engine name to use */
                if (!strcmp(ctrlname, "engine_id"))
                        name = ctrlvalue;
+               else if (!strcmp(ctrlname, "soft_load"))
+                       soft = 1;
                /* Load a dynamic ENGINE */
                else if (!strcmp(ctrlname, "dynamic_path"))
                        {
@@ -147,6 +151,11 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
                        if (!e)
                                {
                                e = ENGINE_by_id(name);
+                               if (!e && soft)
+                                       {
+                                       ERR_clear_error();
+                                       return 1;
+                                       }
                                if (!e)
                                        return 0;
                                }
@@ -155,7 +164,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
                         */
                        if (!strcmp(ctrlvalue, "EMPTY"))
                                ctrlvalue = NULL;
-                       else if (!strcmp(ctrlname, "init"))
+                       if (!strcmp(ctrlname, "init"))
                                {
                                if (!NCONF_get_number_e(cnf, value, "init", &do_init))
                                        goto err;