You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

  1. --- a/src/lib-dcrypt/dcrypt-openssl.c
  2. +++ b/src/lib-dcrypt/dcrypt-openssl.c
  3. @@ -17,10 +17,12 @@
  4. #include <openssl/bio.h>
  5. #include <openssl/pem.h>
  6. #include <openssl/x509.h>
  7. -#include <openssl/engine.h>
  8. #include <openssl/hmac.h>
  9. #include <openssl/objects.h>
  10. #include <openssl/bn.h>
  11. +#ifndef OPENSSL_NO_ENGINE
  12. +#include <openssl/engine.h>
  13. +#endif
  14. #include "dcrypt.h"
  15. #include "dcrypt-private.h"
  16. @@ -179,11 +181,13 @@ static bool dcrypt_openssl_error(const char **error_r)
  17. static bool dcrypt_openssl_initialize(const struct dcrypt_settings *set,
  18. const char **error_r)
  19. {
  20. +#ifndef OPENSSL_NO_ENGINE
  21. if (set->crypto_device != NULL && set->crypto_device[0] != '\0') {
  22. if (dovecot_openssl_common_global_set_engine(
  23. set->crypto_device, error_r) <= 0)
  24. return FALSE;
  25. }
  26. +#endif
  27. return TRUE;
  28. }
  29. --- a/src/lib-ssl-iostream/dovecot-openssl-common.c
  30. +++ b/src/lib-ssl-iostream/dovecot-openssl-common.c
  31. @@ -5,11 +5,14 @@
  32. #include "dovecot-openssl-common.h"
  33. #include <openssl/ssl.h>
  34. -#include <openssl/engine.h>
  35. #include <openssl/rand.h>
  36. +#ifndef OPENSSL_NO_ENGINE
  37. +#include <openssl/engine.h>
  38. -static int openssl_init_refcount = 0;
  39. static ENGINE *dovecot_openssl_engine;
  40. +#endif
  41. +
  42. +static int openssl_init_refcount = 0;
  43. #ifdef HAVE_SSL_NEW_MEM_FUNCS
  44. static void *dovecot_openssl_malloc(size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
  45. @@ -75,17 +78,21 @@ bool dovecot_openssl_common_global_unref(void)
  46. if (--openssl_init_refcount > 0)
  47. return TRUE;
  48. +#ifndef OPENSSL_NO_ENGINE
  49. if (dovecot_openssl_engine != NULL) {
  50. ENGINE_finish(dovecot_openssl_engine);
  51. dovecot_openssl_engine = NULL;
  52. }
  53. +#endif
  54. /* OBJ_cleanup() is called automatically by EVP_cleanup() in
  55. newer versions. Doesn't hurt to call it anyway. */
  56. OBJ_cleanup();
  57. #ifdef HAVE_SSL_COMP_FREE_COMPRESSION_METHODS
  58. SSL_COMP_free_compression_methods();
  59. #endif
  60. +#ifndef OPENSSL_NO_ENGINE
  61. ENGINE_cleanup();
  62. +#endif
  63. EVP_cleanup();
  64. CRYPTO_cleanup_all_ex_data();
  65. #ifdef HAVE_OPENSSL_AUTO_THREAD_DEINIT
  66. @@ -107,6 +114,7 @@ bool dovecot_openssl_common_global_unref(void)
  67. int dovecot_openssl_common_global_set_engine(const char *engine,
  68. const char **error_r)
  69. {
  70. +#ifndef OPENSSL_NO_ENGINE
  71. if (dovecot_openssl_engine != NULL)
  72. return 1;
  73. @@ -128,5 +136,6 @@ int dovecot_openssl_common_global_set_engine(const char *engine,
  74. dovecot_openssl_engine = NULL;
  75. return -1;
  76. }
  77. +#endif
  78. return 1;
  79. }