summarylogtreecommitdiffstats
path: root/no_sslv3.patch
blob: d009103cbf8b840b7354d2c1edbc63d0c1d08816 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
From b1afb00818c8d269c52d4b914e62fd5a9985df69 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Wed, 27 Apr 2016 21:10:03 +0200
Subject: [PATCH] Drop explicit support SSLv3 and TLSv1

There is no addedd value in using only SSLv3 or TLSv1. With current openssl
implementation the sslv3 functions can be disabled and TLSv1 functions may be
removed as well. Further the TLSv1 function offers the TLSv1 protocol while
we have today upto TLSv1.2.

Therefore I remove the explicit SSLv3 and TLSv1 functions and use only SSLv23
function which is the only one which supports multiple SSL versions.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
 man/tlsdate.1              |  4 +---
 src/tlsdate-helper-plan9.c | 38 ++++++++++++--------------------------
 src/tlsdate-helper.c       | 44 +++++++++++++++-----------------------------
 src/tlsdate-helper.h       |  2 --
 src/tlsdate.c              |  6 +-----
 src/tlsdate.h              |  2 --
 6 files changed, 29 insertions(+), 67 deletions(-)

diff --git a/man/tlsdate.1 b/man/tlsdate.1
index b052e48..fce06cd 100644
--- a/man/tlsdate.1
+++ b/man/tlsdate.1
@@ -5,7 +5,7 @@
 .SH NAME
 tlsdate \- secure parasitic rdate replacement
 .SH SYNOPSIS
-.B tlsdate [\-hnvVstlw] [\-H [hostname]] [\-p [port]] [\-P [sslv23|sslv3|tlsv1]] \
+.B tlsdate [\-hnvVstlw] [\-H [hostname]] [\-p [port]] \
 [\-\-certdir [dirname]] [\-x [\-\-proxy] proxy\-type://proxyhost:proxyport]
 .SH DESCRIPTION
 .B tlsdate
@@ -30,8 +30,6 @@ Set remote hostname (default: 'google.com')
 Do not set the system clock to the time of the remote server
 .IP "\-p | \-\-port [port]"
 Set remote port (default: '443')
-.IP "\-P | \-\-protocol [sslv23|sslv3|tlsv1]"
-Set protocol to use when communicating with server (default: 'tlsv1')
 .IP "\-C | \-\-certdir [dirname]"
 Set the local directory where certificates are located
 (default: '/etc/ssl/certs')
diff --git a/src/tlsdate-helper-plan9.c b/src/tlsdate-helper-plan9.c
index 3c532aa..369d168 100644
--- a/src/tlsdate-helper-plan9.c
+++ b/src/tlsdate-helper-plan9.c
@@ -974,23 +974,10 @@ run_ssl (uint32_t *time_map, int time_is_an_illusion)
   SSL_library_init();
 
   ctx = NULL;
-  if (0 == strcmp("sslv23", protocol))
-  {
-    verb ("V: using SSLv23_client_method()\n");
-    ctx = SSL_CTX_new(SSLv23_client_method());
-  } else if (0 == strcmp("sslv3", protocol))
-  {
-    verb ("V: using SSLv3_client_method()\n");
-    ctx = SSL_CTX_new(SSLv3_client_method());
-  } else if (0 == strcmp("tlsv1", protocol))
-  {
-    verb ("V: using TLSv1_client_method()\n");
-    ctx = SSL_CTX_new(TLSv1_client_method());
-  } else
-    die("Unsupported protocol `%s'\n", protocol);
-
+  verb ("V: using SSLv23_client_method()\n");
+  ctx = SSL_CTX_new(SSLv23_client_method());
   if (ctx == NULL)
-    die("OpenSSL failed to support protocol `%s'\n", protocol);
+    die("OpenSSL failed to support protocol `sslv23'\n");
 
   verb("V: Using OpenSSL for SSL\n");
   if (ca_racket)
@@ -1077,20 +1064,19 @@ main(int argc, char **argv)
   int timewarp;
   int leap;
 
-  if (argc != 12)
+  if (argc != 11)
     return 1;
   host = argv[1];
   hostname_to_verify = argv[1];
   port = argv[2];
-  protocol = argv[3];
-  ca_cert_container = argv[6];
-  ca_racket = (0 != strcmp ("unchecked", argv[4]));
-  verbose = (0 != strcmp ("quiet", argv[5]));
-  setclock = (0 == strcmp ("setclock", argv[7]));
-  showtime = (0 == strcmp ("showtime", argv[8]));
-  timewarp = (0 == strcmp ("timewarp", argv[9]));
-  leap = (0 == strcmp ("leapaway", argv[10]));
-  proxy = (0 == strcmp ("none", argv[11]) ? NULL : argv[11]);
+  ca_cert_container = argv[5];
+  ca_racket = (0 != strcmp ("unchecked", argv[3]));
+  verbose = (0 != strcmp ("quiet", argv[4]));
+  setclock = (0 == strcmp ("setclock", argv[6]));
+  showtime = (0 == strcmp ("showtime", argv[7]));
+  timewarp = (0 == strcmp ("timewarp", argv[8]));
+  leap = (0 == strcmp ("leapaway", argv[9]));
+  proxy = (0 == strcmp ("none", argv[10]) ? NULL : argv[10]);
 
   if (timewarp)
   {
diff --git a/src/tlsdate-helper.c b/src/tlsdate-helper.c
index 877c67e..1fe48d9 100644
--- a/src/tlsdate-helper.c
+++ b/src/tlsdate-helper.c
@@ -1129,23 +1129,10 @@ run_ssl (uint32_t *time_map, int time_is_an_illusion, int http)
   SSL_library_init();
 
   ctx = NULL;
-  if (0 == strcmp("sslv23", protocol))
-  {
-    verb ("V: using SSLv23_client_method()");
-    ctx = SSL_CTX_new(SSLv23_client_method());
-  } else if (0 == strcmp("sslv3", protocol))
-  {
-    verb ("V: using SSLv3_client_method()");
-    ctx = SSL_CTX_new(SSLv3_client_method());
-  } else if (0 == strcmp("tlsv1", protocol))
-  {
-    verb ("V: using TLSv1_client_method()");
-    ctx = SSL_CTX_new(TLSv1_client_method());
-  } else
-    die("Unsupported protocol `%s'", protocol);
-
+  verb ("V: using SSLv23_client_method()");
+  ctx = SSL_CTX_new(SSLv23_client_method());
   if (ctx == NULL)
-    die("OpenSSL failed to support protocol `%s'", protocol);
+    die("OpenSSL failed to support protocol `sslv23'");
 
   verb("V: Using OpenSSL for SSL");
   if (ca_racket)
@@ -1257,23 +1244,22 @@ main(int argc, char **argv)
   int leap;
   int http;
 
-  if (argc != 13)
+  if (argc != 12)
     return 1;
   host = argv[1];
   hostname_to_verify = argv[1];
   port = argv[2];
-  protocol = argv[3];
-  ca_cert_container = argv[6];
-  ca_racket = (0 != strcmp ("unchecked", argv[4]));
-  verbose = (0 != strcmp ("quiet", argv[5]));
-  verbose_debug = (0 != strcmp ("verbose", argv[5]));
-  setclock = (0 == strcmp ("setclock", argv[7]));
-  showtime = (0 == strcmp ("showtime", argv[8]));
-  showtime_raw = (0 == strcmp ("showtime=raw", argv[8]));
-  timewarp = (0 == strcmp ("timewarp", argv[9]));
-  leap = (0 == strcmp ("leapaway", argv[10]));
-  proxy = (0 == strcmp ("none", argv[11]) ? NULL : argv[11]);
-  http = (0 == (strcmp("http", argv[12])));
+  ca_cert_container = argv[5];
+  ca_racket = (0 != strcmp ("unchecked", argv[3]));
+  verbose = (0 != strcmp ("quiet", argv[4]));
+  verbose_debug = (0 != strcmp ("verbose", argv[4]));
+  setclock = (0 == strcmp ("setclock", argv[6]));
+  showtime = (0 == strcmp ("showtime", argv[7]));
+  showtime_raw = (0 == strcmp ("showtime=raw", argv[7]));
+  timewarp = (0 == strcmp ("timewarp", argv[8]));
+  leap = (0 == strcmp ("leapaway", argv[9]));
+  proxy = (0 == strcmp ("none", argv[10]) ? NULL : argv[10]);
+  http = (0 == (strcmp("http", argv[11])));
 
   /* Initalize warp_time with RECENT_COMPILE_DATE */
   clock_init_time(&warp_time, RECENT_COMPILE_DATE, 0);
diff --git a/src/tlsdate-helper.h b/src/tlsdate-helper.h
index 64e4092..810ee7e 100644
--- a/src/tlsdate-helper.h
+++ b/src/tlsdate-helper.h
@@ -118,8 +118,6 @@ static const char *hostname_to_verify;
 
 static const char *port;
 
-static const char *protocol;
-
 static char *proxy;
 
 static const char *ca_cert_container;
diff --git a/src/tlsdate.c b/src/tlsdate.c
index dd7f993..c85ca35 100644
--- a/src/tlsdate.c
+++ b/src/tlsdate.c
@@ -88,7 +88,6 @@ usage (void)
            " [-n|--dont-set-clock]\n"
            " [-H|--host] [hostname|ip]\n"
            " [-p|--port] [port number]\n"
-           " [-P|--protocol] [sslv23|sslv3|tlsv1]\n"
            " [-C|--certcontainer] [dirname|filename]\n"
            " [-v|--verbose]\n"
            " [-V|--showtime] [human|raw]\n"
@@ -108,7 +107,6 @@ main (int argc, char **argv)
   int setclock;
   const char *host;
   const char *port;
-  const char *protocol;
   const char *ca_cert_container;
   int timewarp;
   int leap;
@@ -117,7 +115,6 @@ main (int argc, char **argv)
 
   host = DEFAULT_HOST;
   port = DEFAULT_PORT;
-  protocol = DEFAULT_PROTOCOL;
   ca_cert_container = DEFAULT_CERTFILE;
   verbose = 0;
   ca_racket = 1;
@@ -176,7 +173,7 @@ main (int argc, char **argv)
           port = optarg;
           break;
         case 'P':
-          protocol = optarg;
+          /* ignore for compatibility */
           break;
         case 'n':
           setclock = 0;
@@ -219,7 +216,6 @@ main (int argc, char **argv)
           "tlsdate",
           host,
           port,
-          protocol,
           (ca_racket ? "racket" : "unchecked"),
           (verbose ? "verbose" : "quiet"),
           ca_cert_container,
diff --git a/src/tlsdate.h b/src/tlsdate.h
index 52305eb..d236b67 100644
--- a/src/tlsdate.h
+++ b/src/tlsdate.h
@@ -27,7 +27,6 @@
 #define DEFAULT_HOST "google.com"
 #define DEFAULT_PORT "443"
 #define DEFAULT_PROXY "none"
-#define DEFAULT_PROTOCOL "tlsv1"
 #define DEFAULT_CERTDIR "/etc/ssl/certs"
 #define DEFAULT_CERTFILE TLSDATE_CERTFILE
 #define DEFAULT_DAEMON_CACHEDIR "/var/cache/tlsdated"
@@ -239,7 +238,6 @@ typedef struct
   time_t manual_time;
   char *host;
   char *port;
-  char *protocol;
 } tlsdate_options_t;
 
 #endif /* TLSDATE_H */