2015-01-22 11:40:55 +08:00
|
|
|
/*
|
2016-05-18 02:24:46 +08:00
|
|
|
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2002-02-23 09:00:44 +08:00
|
|
|
*
|
2016-05-18 02:24:46 +08:00
|
|
|
* Licensed under the OpenSSL license (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
|
2002-02-23 09:00:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/crypto.h>
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
2017-08-22 20:35:43 +08:00
|
|
|
#include "internal/conf.h"
|
2002-02-23 09:00:44 +08:00
|
|
|
#include <openssl/x509.h>
|
|
|
|
#include <openssl/asn1.h>
|
2016-03-19 02:30:20 +08:00
|
|
|
#include <openssl/engine.h>
|
2002-02-23 09:00:44 +08:00
|
|
|
|
2017-11-12 05:23:12 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
# define strdup _strdup
|
|
|
|
#endif
|
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
/*
|
|
|
|
* This is the automatic configuration loader: it is called automatically by
|
|
|
|
* OpenSSL when any of a number of standard initialisation functions are
|
|
|
|
* called, unless this is overridden by calling OPENSSL_no_config()
|
2002-02-23 09:00:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int openssl_configured = 0;
|
|
|
|
|
2016-02-15 04:25:54 +08:00
|
|
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
2016-06-13 09:49:40 +08:00
|
|
|
void OPENSSL_config(const char *appname)
|
2016-02-09 00:43:03 +08:00
|
|
|
{
|
2016-02-10 22:55:48 +08:00
|
|
|
OPENSSL_INIT_SETTINGS settings;
|
2016-02-10 05:01:25 +08:00
|
|
|
|
2016-02-10 22:55:48 +08:00
|
|
|
memset(&settings, 0, sizeof(settings));
|
2016-06-13 09:49:40 +08:00
|
|
|
if (appname != NULL)
|
|
|
|
settings.appname = strdup(appname);
|
2016-02-10 22:55:48 +08:00
|
|
|
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings);
|
2016-02-09 00:43:03 +08:00
|
|
|
}
|
2016-02-15 04:25:54 +08:00
|
|
|
#endif
|
2016-02-09 00:43:03 +08:00
|
|
|
|
2016-06-13 09:49:40 +08:00
|
|
|
void openssl_config_int(const char *appname)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
|
|
|
if (openssl_configured)
|
|
|
|
return;
|
2002-02-23 09:00:44 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
OPENSSL_load_builtin_modules();
|
2003-01-31 01:39:26 +08:00
|
|
|
#ifndef OPENSSL_NO_ENGINE
|
2015-01-22 11:40:55 +08:00
|
|
|
/* Need to load ENGINEs */
|
|
|
|
ENGINE_load_builtin_engines();
|
2003-01-31 01:39:26 +08:00
|
|
|
#endif
|
2015-01-22 11:40:55 +08:00
|
|
|
ERR_clear_error();
|
2015-09-12 02:56:32 +08:00
|
|
|
#ifndef OPENSSL_SYS_UEFI
|
2016-06-13 09:49:40 +08:00
|
|
|
CONF_modules_load_file(NULL, appname,
|
2015-01-22 11:40:55 +08:00
|
|
|
CONF_MFLAGS_DEFAULT_SECTION |
|
2015-01-26 10:07:20 +08:00
|
|
|
CONF_MFLAGS_IGNORE_MISSING_FILE);
|
2015-09-12 02:56:32 +08:00
|
|
|
#endif
|
2015-11-04 22:00:12 +08:00
|
|
|
openssl_configured = 1;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2002-02-23 09:00:44 +08:00
|
|
|
|
2016-04-12 19:20:16 +08:00
|
|
|
void openssl_no_config_int(void)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
|
|
|
openssl_configured = 1;
|
|
|
|
}
|