conf_sap.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  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
  8. */
  9. #include <stdio.h>
  10. #include <openssl/crypto.h>
  11. #include "internal/cryptlib.h"
  12. #include "internal/conf.h"
  13. #include <openssl/x509.h>
  14. #include <openssl/asn1.h>
  15. #include <openssl/engine.h>
  16. #ifdef _WIN32
  17. # define strdup _strdup
  18. #endif
  19. /*
  20. * This is the automatic configuration loader: it is called automatically by
  21. * OpenSSL when any of a number of standard initialisation functions are
  22. * called, unless this is overridden by calling OPENSSL_no_config()
  23. */
  24. static int openssl_configured = 0;
  25. #if OPENSSL_API_COMPAT < 0x10100000L
  26. void OPENSSL_config(const char *appname)
  27. {
  28. OPENSSL_INIT_SETTINGS settings;
  29. memset(&settings, 0, sizeof(settings));
  30. if (appname != NULL)
  31. settings.appname = strdup(appname);
  32. OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings);
  33. }
  34. #endif
  35. void openssl_config_int(const char *appname)
  36. {
  37. if (openssl_configured)
  38. return;
  39. OPENSSL_load_builtin_modules();
  40. #ifndef OPENSSL_NO_ENGINE
  41. /* Need to load ENGINEs */
  42. ENGINE_load_builtin_engines();
  43. #endif
  44. ERR_clear_error();
  45. #ifndef OPENSSL_SYS_UEFI
  46. CONF_modules_load_file(NULL, appname,
  47. CONF_MFLAGS_DEFAULT_SECTION |
  48. CONF_MFLAGS_IGNORE_MISSING_FILE);
  49. #endif
  50. openssl_configured = 1;
  51. }
  52. void openssl_no_config_int(void)
  53. {
  54. openssl_configured = 1;
  55. }