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.

78 lines
2.1 KiB

  1. From 5bc932f7a71ede7d8ecd9d88804af95a2eb955c0 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Sun, 3 Nov 2019 15:34:33 -0800
  4. Subject: [PATCH] reds: Fix compilation without deprecated OpenSSL 1.1 APIs
  5. Missing headers for BN_ and RSA_ functions.
  6. Initialization is deprecated with 1.1.
  7. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  8. Acked-by: Frediano Ziglio <fziglio@redhat.com>
  9. ---
  10. AUTHORS hunk removed as it does not apply (with 0.14.2 at least)
  11. AUTHORS | 1 +
  12. server/reds.c | 24 ++++++++++++++++--------
  13. 2 files changed, 17 insertions(+), 8 deletions(-)
  14. diff --git a/server/reds.c b/server/reds.c
  15. index c55aa3f8..dc03ef3a 100644
  16. --- a/server/reds.c
  17. +++ b/server/reds.c
  18. @@ -36,7 +36,9 @@
  19. #include <ws2tcpip.h>
  20. #endif
  21. +#include <openssl/bn.h>
  22. #include <openssl/err.h>
  23. +#include <openssl/rsa.h>
  24. #if HAVE_SASL
  25. #include <sasl/sasl.h>
  26. @@ -2838,13 +2840,8 @@ static void openssl_thread_setup(void)
  27. CRYPTO_set_id_callback(pthreads_thread_id);
  28. CRYPTO_set_locking_callback(pthreads_locking_callback);
  29. }
  30. -#else
  31. -static inline void openssl_thread_setup(void)
  32. -{
  33. -}
  34. -#endif
  35. -static gpointer openssl_global_init(gpointer arg)
  36. +static gpointer openssl_global_init_once(gpointer arg)
  37. {
  38. SSL_library_init();
  39. SSL_load_error_strings();
  40. @@ -2854,9 +2851,20 @@ static gpointer openssl_global_init(gpointer arg)
  41. return NULL;
  42. }
  43. -static int reds_init_ssl(RedsState *reds)
  44. +static inline void openssl_global_init(void)
  45. {
  46. static GOnce openssl_once = G_ONCE_INIT;
  47. + g_once(&openssl_once, openssl_global_init_once, NULL);
  48. +}
  49. +
  50. +#else
  51. +static inline void openssl_global_init(void)
  52. +{
  53. +}
  54. +#endif
  55. +
  56. +static int reds_init_ssl(RedsState *reds)
  57. +{
  58. const SSL_METHOD *ssl_method;
  59. int return_code;
  60. /* Limit connection to TLSv1.1 or newer.
  61. @@ -2865,7 +2873,7 @@ static int reds_init_ssl(RedsState *reds)
  62. long ssl_options = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION | SSL_OP_NO_TLSv1;
  63. /* Global system initialization*/
  64. - g_once(&openssl_once, openssl_global_init, NULL);
  65. + openssl_global_init();
  66. /* Create our context*/
  67. /* SSLv23_method() handles TLSv1.x in addition to SSLv2/v3 */