Skip to content

Commit ebf5cd2

Browse files
ralishVasiliy Evseenko
authored andcommitted
Fix TLS setting to use TLS 1.x (support TLS 1.1/1.2)
When we run using "--tls" (default) we create the SSL context with a TLSv1_*_method(), however, this _only_ supports TLS 1.0 connections. In contrast, when we run with "--ssl" we use a SSLv23_*_method() which allows all supported protocols. We block SSL 2.0 by passing in the SSL_OP_NO_SSLv2 flag in SSL_CTX_set_options. This results in the somewhat counterintuitive situation where the supported protocols are: * --tls: TLS 1.0 * --ssl: SSL 3.0, TLS 1.0, TLS 1.1, TLS 1.2 This patch fixes the handling of "--tls" so that it supports TLS 1.x while ensuring SSL 3.0 is blocked (SSL 2.0 is always blocked). This all assumes an OpenSSL library capable of supports newer TLS versions, otherwise, the above change will have no effect on stud's behaviour (ie. --ssl supports SSL 3.0/TLS 1.0, --tls supports TLS 1.0).
1 parent 5b2077a commit ebf5cd2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

stud.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,14 @@ SSL_CTX *make_ctx(const char *pemfile) {
640640
#endif
641641

642642
if (CONFIG->ETYPE == ENC_TLS) {
643-
ctx = SSL_CTX_new((CONFIG->PMODE == SSL_CLIENT) ?
644-
TLSv1_client_method() : TLSv1_server_method());
645-
} else if (CONFIG->ETYPE == ENC_SSL) {
646-
ctx = SSL_CTX_new((CONFIG->PMODE == SSL_CLIENT) ?
647-
SSLv23_client_method() : SSLv23_server_method());
648-
} else {
643+
ssloptions |= SSL_OP_NO_SSLv3;
644+
} else if (CONFIG->ETYPE != ENC_SSL) {
649645
assert(CONFIG->ETYPE == ENC_TLS || CONFIG->ETYPE == ENC_SSL);
650646
return NULL; // Won't happen, but gcc was complaining
651647
}
652648

649+
ctx = SSL_CTX_new((CONFIG->PMODE == SSL_CLIENT) ?
650+
SSLv23_client_method() : SSLv23_server_method());
653651
SSL_CTX_set_options(ctx, ssloptions);
654652
SSL_CTX_set_info_callback(ctx, info_callback);
655653

0 commit comments

Comments
 (0)