Skip to content

Commit bdc9a3f

Browse files
committed
implement -no_tlsext
Some servers implement TLS1.0 but are intolerant to any and all extensions sent by clients. Implement option to disable sending of the extensions completely. # Conflicts: # ssl/t1_lib.c
1 parent 24d8376 commit bdc9a3f

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

apps/s_client.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ static void sc_usage(void)
443443
" -keymatexport label - Export keying material using label\n");
444444
BIO_printf(bio_err,
445445
" -keymatexportlen len - Export len bytes of keying material (default 20)\n");
446+
BIO_printf(bio_err,
447+
" -no_tlsext - Don't send any TLS extensions (breaks servername, NPN and ALPN among others)\n");
448+
446449
}
447450

448451
#ifndef OPENSSL_NO_TLSEXT

doc/apps/s_client.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ B<openssl> B<s_client>
4949
[B<-engine id>]
5050
[B<-tlsextdebug>]
5151
[B<-no_ticket>]
52+
[B<-no_tlsext>]
5253
[B<-sess_out filename>]
5354
[B<-sess_in filename>]
5455
[B<-rand file(s)>]
@@ -252,6 +253,13 @@ print out a hex dump of any TLS extensions received from the server.
252253

253254
disable RFC4507bis session ticket support.
254255

256+
=item B<-no_tlsext>
257+
258+
disable sending any and all TLS extensions in Client Hello message.
259+
260+
Note that this will break other options like B<-servername>, B<-nextprotoneg>
261+
or B<-alpn>.
262+
255263
=item B<-sess_out filename>
256264

257265
output SSL session to B<filename>

doc/ssl/SSL_CONF_cmd.pod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ Disables support for SSL/TLS compression, same as setting B<SSL_OP_NO_COMPRESS>.
127127

128128
Disables support for session tickets, same as setting B<SSL_OP_NO_TICKET>.
129129

130+
=item B<-no_tlsext>
131+
132+
Disables sending any and all TLS extensions in Client Hello, including session
133+
tickets, supported curves, heartbeat, etc. same as setting B<SSL_OP_NO_TLSEXT>.
134+
130135
=item B<-serverpref>
131136

132137
Use server and not client preference order when determining which cipher suite,
@@ -296,6 +301,11 @@ determining which cipher suite, signature algorithm or elliptic curve
296301
to use for an incoming connection. Equivalent to
297302
B<SSL_OP_CIPHER_SERVER_PREFERENCE>. Only used by servers.
298303

304+
B<TLSExtensions>: send TLS extensions in Client Hello, set by default.
305+
Note that disabling extensions will break other options like SRP, ALPN, NPN or
306+
server name indication among others. Inverse of B<SSL_OP_NO_TLSEXT>: that is
307+
B<-TLSExtensions> is the same as setting B<SSL_OP_NO_TLSEXT>.
308+
299309
B<NoResumptionOnRenegotiation> set
300310
B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> flag. Only used by servers.
301311

doc/ssl/SSL_CTX_set_options.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ Do not use the SSLv3 protocol.
198198

199199
Do not use the TLSv1 protocol.
200200

201+
=item SSL_OP_NO_TLSEXT
202+
203+
Don't send any TLS extensions in client hello, even if it will break other
204+
options like SRP, ALPN, NPN, server name indication, etc.
205+
206+
Required for interoperability with particularly broken servers that don't
207+
tolerate any extensions in Client Hello.
208+
201209
=item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
202210

203211
When performing renegotiation as a server, always start a new session

ssl/ssl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,10 @@ struct ssl_session_st {
595595
/* Refers to ancient SSLREF and SSLv2, retained for compatibility */
596596
# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0
597597

598+
/* Disables sending any TLS extensions in client hello, even if required
599+
* by used protocol version, ciphers or other options */
600+
# define SSL_OP_NO_TLSEXT 0x00000400L
601+
598602
/*
599603
* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in
600604
* OpenSSL 0.9.6d. Usually (depending on the application protocol) the

ssl/ssl_conf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ typedef struct {
9494
{str, (int)(sizeof(str) - 1), SSL_TFLAG_SERVER, flag}
9595
#define SSL_FLAG_TBL_CLI(str, flag) \
9696
{str, (int)(sizeof(str) - 1), SSL_TFLAG_CLIENT, flag}
97+
#define SSL_FLAG_TBL_CLI_INV(str, flag) \
98+
{str, (int)(sizeof(str) - 1), SSL_TFLAG_INV|SSL_TFLAG_CLIENT, flag}
9799
#define SSL_FLAG_TBL_INV(str, flag) \
98100
{str, (int)(sizeof(str) - 1), SSL_TFLAG_INV|SSL_TFLAG_BOTH, flag}
99101
#define SSL_FLAG_TBL_SRV_INV(str, flag) \
@@ -216,6 +218,7 @@ static int ctrl_str_option(SSL_CONF_CTX *cctx, const char *cmd)
216218
SSL_FLAG_TBL_CERT("debug_broken_protocol",
217219
SSL_CERT_FLAG_BROKEN_PROTOCOL),
218220
#endif
221+
SSL_FLAG_TBL_CLI("no_tlsext", SSL_OP_NO_TLSEXT),
219222
};
220223
cctx->tbl = ssl_option_single;
221224
cctx->ntbl = sizeof(ssl_option_single) / sizeof(ssl_flag_tbl);
@@ -352,6 +355,7 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
352355
SSL_FLAG_TBL_SRV("ECDHSingle", SSL_OP_SINGLE_ECDH_USE),
353356
SSL_FLAG_TBL("UnsafeLegacyRenegotiation",
354357
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION),
358+
SSL_FLAG_TBL_CLI_INV("TLSExtensions", SSL_OP_NO_TLSEXT),
355359
};
356360
if (!(cctx->flags & SSL_CONF_FLAG_FILE))
357361
return -2;

ssl/t1_lib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,10 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf,
12211221
if (ret >= limit)
12221222
return NULL; /* this really never occurs, but ... */
12231223

1224+
/* skip all options if asked for it */
1225+
if (s->options & SSL_OP_NO_TLSEXT)
1226+
goto done;
1227+
12241228
if (s->tlsext_hostname != NULL) {
12251229
/* Add TLS extension servername to the Client Hello message */
12261230
unsigned long size_str;

0 commit comments

Comments
 (0)