--- /dev/null
+/*
+ * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+#include "app_libctx.h"
+#include "apps.h"
+
+static OSSL_LIB_CTX *app_libctx = NULL;
+static const char *app_propq = NULL;
+
+int app_set_propq(const char *arg)
+{
+ app_propq = arg;
+ return 1;
+}
+
+const char *app_get0_propq(void)
+{
+ return app_propq;
+}
+
+OSSL_LIB_CTX *app_get0_libctx(void)
+{
+ return app_libctx;
+}
+
+OSSL_LIB_CTX *app_create_libctx(void)
+{
+ /*
+ * Load the NULL provider into the default library context and create a
+ * library context which will then be used for any OPT_PROV options.
+ */
+ if (app_libctx == NULL) {
+ if (!app_provider_load(NULL, "null")) {
+ opt_printf_stderr( "Failed to create null provider\n");
+ return NULL;
+ }
+ app_libctx = OSSL_LIB_CTX_new();
+ }
+ if (app_libctx == NULL)
+ opt_printf_stderr("Failed to create library context\n");
+ return app_libctx;
+}
+
unsigned long mask;
} NAME_EX_TBL;
-static OSSL_LIB_CTX *app_libctx = NULL;
-
static int set_table_opts(unsigned long *flags, const char *arg,
const NAME_EX_TBL * in_tbl);
static int set_multi_opts(unsigned long *flags, const char *arg,
return OPENSSL_strdup(tpass);
}
-OSSL_LIB_CTX *app_get0_libctx(void)
-{
- return app_libctx;
-}
-
-static const char *app_propq = NULL;
-
-int app_set_propq(const char *arg)
-{
- app_propq = arg;
- return 1;
-}
-
-const char *app_get0_propq(void)
-{
- return app_propq;
-}
-
-OSSL_LIB_CTX *app_create_libctx(void)
-{
- /*
- * Load the NULL provider into the default library context and create a
- * library context which will then be used for any OPT_PROV options.
- */
- if (app_libctx == NULL) {
-
- if (!app_provider_load(NULL, "null")) {
- BIO_puts(bio_err, "Failed to create null provider\n");
- return NULL;
- }
- app_libctx = OSSL_LIB_CTX_new();
- }
- if (app_libctx == NULL)
- BIO_puts(bio_err, "Failed to create library context\n");
- return app_libctx;
-}
-
CONF *app_load_config_bio(BIO *in, const char *filename)
{
long errorline = -1;
CONF *conf;
int i;
- conf = NCONF_new_ex(app_libctx, NULL);
+ conf = NCONF_new_ex(app_get0_libctx(), NULL);
i = NCONF_load_bio(conf, in, &errorline);
if (i > 0)
return conf;
BIO_free(in);
} else {
/* Return empty config if filename is empty string. */
- conf = NCONF_new_ex(app_libctx, NULL);
+ conf = NCONF_new_ex(app_get0_libctx(), NULL);
}
return conf;
}
# Source for libapps
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
columns.c app_params.c names.c app_provider.c app_x509.c http_server.c \
- engine.c engine_loader.c
+ engine.c engine_loader.c app_libctx.c
IF[{- !$disabled{apps} -}]
LIBS{noinst}=../libapps.a