aboutsummaryrefslogtreecommitdiffstats
path: root/testing/nut/openssl-1.1.patch
blob: e7a28845830b65c066b5bd70e23136affa26bdf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From fcbf18c92918ce5e81d0aab62a7aed5c2245ea4d Mon Sep 17 00:00:00 2001
From: Eneas U de Queiroz <cote2004-github@yahoo.com>
Date: Fri, 1 Jun 2018 11:17:28 -0300
Subject: [PATCH] Add compatibility with openssl 1.1.0

Minor adjustments were needed:
* Openssl 1.1 libs do not need to be initialized.
* TLSv*_method became TLS_*_method.

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
---
 clients/upsclient.c        | 5 ++++-
 m4/nut_check_libopenssl.m4 | 2 +-
 server/netssl.c            | 7 +++++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/clients/upsclient.c b/clients/upsclient.c
index b90587b00..053d60fb0 100644
--- a/clients/upsclient.c
+++ b/clients/upsclient.c
@@ -316,10 +316,13 @@ int upscli_init(int certverify, const char *certpath,
 	
 #ifdef WITH_OPENSSL
 	
+# if OPENSSL_VERSION_NUMBER < 0x10100000L
 	SSL_library_init();
 	SSL_load_error_strings();
+#  define TLS_client_method TLSv1_client_method
+# endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
 
-	ssl_method = TLSv1_client_method();
+	ssl_method = TLS_client_method();
 
 	if (!ssl_method) {
 		return 0;
diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4
index 1b875077b..7eb401cd9 100644
--- a/m4/nut_check_libopenssl.m4
+++ b/m4/nut_check_libopenssl.m4
@@ -58,7 +58,7 @@ if test -z "${nut_have_libopenssl_seen}"; then
 
 	dnl check if openssl is usable
 	AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT])
-	AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no])
+	AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no])
 
 	if test "${nut_have_openssl}" = "yes"; then
 		nut_with_ssl="yes"
diff --git a/server/netssl.c b/server/netssl.c
index c2f409899..0289e296f 100644
--- a/server/netssl.c
+++ b/server/netssl.c
@@ -387,12 +387,15 @@ void ssl_init(void)
 
 #ifdef WITH_OPENSSL
 
+# if OPENSSL_VERSION_NUMBER < 0x10100000L
 	SSL_load_error_strings();
 	SSL_library_init();
+#  define TLS_server_method TLSv1_server_method
+# endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
 
-	if ((ssl_method = TLSv1_server_method()) == NULL) {
+	if ((ssl_method = TLS_server_method()) == NULL) {
 		ssl_debug();
-		fatalx(EXIT_FAILURE, "TLSv1_server_method failed");
+		fatalx(EXIT_FAILURE, "TLS_server_method failed");
 	}
 
 	if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) {