]>
Commit | Line | Data |
---|---|---|
0f113f3e | 1 | /* |
3c2bdd7d | 2 | * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved. |
e84be9b4 | 3 | * |
2044d382 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
62867571 RS |
5 | * this file except in compliance with the License. You can obtain a copy |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
e84be9b4 DSH |
8 | */ |
9 | ||
10 | #include <stdio.h> | |
11 | #include <openssl/crypto.h> | |
b39fc560 | 12 | #include "internal/cryptlib.h" |
176db6dc | 13 | #include "internal/conf.h" |
e84be9b4 DSH |
14 | #include <openssl/x509.h> |
15 | #include <openssl/asn1.h> | |
3c27208f | 16 | #include <openssl/engine.h> |
e84be9b4 | 17 | |
3a63c0ed AP |
18 | #ifdef _WIN32 |
19 | # define strdup _strdup | |
20 | #endif | |
21 | ||
0f113f3e MC |
22 | /* |
23 | * This is the automatic configuration loader: it is called automatically by | |
24 | * OpenSSL when any of a number of standard initialisation functions are | |
25 | * called, unless this is overridden by calling OPENSSL_no_config() | |
e84be9b4 DSH |
26 | */ |
27 | ||
28 | static int openssl_configured = 0; | |
29 | ||
00db8c60 | 30 | #ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
cda3ae5b | 31 | void OPENSSL_config(const char *appname) |
7b9f8f7f | 32 | { |
7253fd55 | 33 | OPENSSL_INIT_SETTINGS settings; |
dfbfd067 | 34 | |
7253fd55 | 35 | memset(&settings, 0, sizeof(settings)); |
cda3ae5b RS |
36 | if (appname != NULL) |
37 | settings.appname = strdup(appname); | |
905c9a72 | 38 | settings.flags = DEFAULT_CONF_MFLAGS; |
7253fd55 | 39 | OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings); |
7b9f8f7f | 40 | } |
31305cdf | 41 | #endif |
7b9f8f7f | 42 | |
f148f703 | 43 | int ossl_config_int(const OPENSSL_INIT_SETTINGS *settings) |
0f113f3e | 44 | { |
f4a96507 | 45 | int ret = 0; |
df1f538f VD |
46 | const char *filename; |
47 | const char *appname; | |
48 | unsigned long flags; | |
49 | ||
0f113f3e | 50 | if (openssl_configured) |
df1f538f VD |
51 | return 1; |
52 | ||
53 | filename = settings ? settings->filename : NULL; | |
54 | appname = settings ? settings->appname : NULL; | |
55 | flags = settings ? settings->flags : DEFAULT_CONF_MFLAGS; | |
56 | ||
57 | #ifdef OPENSSL_INIT_DEBUG | |
f148f703 | 58 | fprintf(stderr, "OPENSSL_INIT: ossl_config_int(%s, %s, %lu)\n", |
df1f538f VD |
59 | filename, appname, flags); |
60 | #endif | |
e84be9b4 | 61 | |
984d6c60 | 62 | #ifndef OPENSSL_SYS_UEFI |
df1f538f | 63 | ret = CONF_modules_load_file(filename, appname, flags); |
984d6c60 | 64 | #endif |
434b5845 | 65 | openssl_configured = 1; |
df1f538f | 66 | return ret; |
0f113f3e | 67 | } |
e84be9b4 | 68 | |
f148f703 | 69 | void ossl_no_config_int(void) |
0f113f3e MC |
70 | { |
71 | openssl_configured = 1; | |
72 | } |