2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2002-02-23 01:00:44 +00:00
|
|
|
*
|
2016-05-17 18:24:46 +00: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 01:00:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/crypto.h>
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
2017-08-22 12:35:43 +00:00
|
|
|
#include "internal/conf.h"
|
2002-02-23 01:00:44 +00:00
|
|
|
#include <openssl/x509.h>
|
|
|
|
#include <openssl/asn1.h>
|
2016-03-18 18:30:20 +00:00
|
|
|
#include <openssl/engine.h>
|
2002-02-23 01:00:44 +00:00
|
|
|
|
2017-11-11 21:23:12 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
# define strdup _strdup
|
|
|
|
#endif
|
|
|
|
|
2015-01-22 03:40:55 +00: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 01:00:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int openssl_configured = 0;
|
|
|
|
|
2016-02-14 20:25:54 +00:00
|
|
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
2016-06-13 01:49:40 +00:00
|
|
|
void OPENSSL_config(const char *appname)
|
2016-02-08 16:43:03 +00:00
|
|
|
{
|
2016-02-10 14:55:48 +00:00
|
|
|
OPENSSL_INIT_SETTINGS settings;
|
2016-02-09 21:01:25 +00:00
|
|
|
|
2016-02-10 14:55:48 +00:00
|
|
|
memset(&settings, 0, sizeof(settings));
|
2016-06-13 01:49:40 +00:00
|
|
|
if (appname != NULL)
|
|
|
|
settings.appname = strdup(appname);
|
2016-02-10 14:55:48 +00:00
|
|
|
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings);
|
2016-02-08 16:43:03 +00:00
|
|
|
}
|
2016-02-14 20:25:54 +00:00
|
|
|
#endif
|
2016-02-08 16:43:03 +00:00
|
|
|
|
2016-06-13 01:49:40 +00:00
|
|
|
void openssl_config_int(const char *appname)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
if (openssl_configured)
|
|
|
|
return;
|
2002-02-23 01:00:44 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
OPENSSL_load_builtin_modules();
|
2003-01-30 17:39:26 +00:00
|
|
|
#ifndef OPENSSL_NO_ENGINE
|
2015-01-22 03:40:55 +00:00
|
|
|
/* Need to load ENGINEs */
|
|
|
|
ENGINE_load_builtin_engines();
|
2003-01-30 17:39:26 +00:00
|
|
|
#endif
|
2015-01-22 03:40:55 +00:00
|
|
|
ERR_clear_error();
|
2015-09-11 18:56:32 +00:00
|
|
|
#ifndef OPENSSL_SYS_UEFI
|
2016-06-13 01:49:40 +00:00
|
|
|
CONF_modules_load_file(NULL, appname,
|
2015-01-22 03:40:55 +00:00
|
|
|
CONF_MFLAGS_DEFAULT_SECTION |
|
2015-01-26 02:07:20 +00:00
|
|
|
CONF_MFLAGS_IGNORE_MISSING_FILE);
|
2015-09-11 18:56:32 +00:00
|
|
|
#endif
|
2015-11-04 14:00:12 +00:00
|
|
|
openssl_configured = 1;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
2002-02-23 01:00:44 +00:00
|
|
|
|
2016-04-12 11:20:16 +00:00
|
|
|
void openssl_no_config_int(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
openssl_configured = 1;
|
|
|
|
}
|