0003-Add-compatibility-with-openssl-1.1.0.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From fcbf18c92918ce5e81d0aab62a7aed5c2245ea4d Mon Sep 17 00:00:00 2001
  2. From: Eneas U de Queiroz <cote2004-github@yahoo.com>
  3. Date: Fri, 1 Jun 2018 11:17:28 -0300
  4. Subject: [PATCH] Add compatibility with openssl 1.1.0
  5. Minor adjustments were needed:
  6. * Openssl 1.1 libs do not need to be initialized.
  7. * TLSv*_method became TLS_*_method.
  8. Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
  9. Upstream: https://github.com/networkupstools/nut/pull/558/
  10. [added check for libressl]
  11. Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
  12. ---
  13. clients/upsclient.c | 5 ++++-
  14. m4/nut_check_libopenssl.m4 | 2 +-
  15. server/netssl.c | 7 +++++--
  16. 3 files changed, 10 insertions(+), 4 deletions(-)
  17. diff --git a/clients/upsclient.c b/clients/upsclient.c
  18. index b90587b0..053d60fb 100644
  19. --- a/clients/upsclient.c
  20. +++ b/clients/upsclient.c
  21. @@ -316,10 +316,13 @@ int upscli_init(int certverify, const char *certpath,
  22. #ifdef WITH_OPENSSLdefined(LIBRESSL_VERSION_NUMBER)
  23. +# if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  24. SSL_library_init();
  25. SSL_load_error_strings();
  26. +# define TLS_client_method TLSv1_client_method
  27. +# endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
  28. - ssl_method = TLSv1_client_method();
  29. + ssl_method = TLS_client_method();
  30. if (!ssl_method) {
  31. return 0;
  32. diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4
  33. index 1b875077..7eb401cd 100644
  34. --- a/m4/nut_check_libopenssl.m4
  35. +++ b/m4/nut_check_libopenssl.m4
  36. @@ -58,7 +58,7 @@ if test -z "${nut_have_libopenssl_seen}"; then
  37. dnl check if openssl is usable
  38. AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT])
  39. - AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no])
  40. + AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no])
  41. if test "${nut_have_openssl}" = "yes"; then
  42. nut_with_ssl="yes"
  43. diff --git a/server/netssl.c b/server/netssl.c
  44. index c2f40989..0289e296 100644
  45. --- a/server/netssl.c
  46. +++ b/server/netssl.c
  47. @@ -387,12 +387,15 @@ void ssl_init(void)
  48. #ifdef WITH_OPENSSL
  49. +# if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  50. SSL_load_error_strings();
  51. SSL_library_init();
  52. +# define TLS_server_method TLSv1_server_method
  53. +# endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
  54. - if ((ssl_method = TLSv1_server_method()) == NULL) {
  55. + if ((ssl_method = TLS_server_method()) == NULL) {
  56. ssl_debug();
  57. - fatalx(EXIT_FAILURE, "TLSv1_server_method failed");
  58. + fatalx(EXIT_FAILURE, "TLS_server_method failed");
  59. }
  60. if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) {
  61. --
  62. 2.16.1