Skip to content

Commit 7d559f8

Browse files
committed
tac_plus-ng/packet.c: be more verbose when rejecting TLS connections
1 parent 57c2f73 commit 7d559f8

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

tac_plus-ng/headers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ struct context_logfile {
10351035
};
10361036

10371037
void cleanup(struct context *, int);
1038+
void reject_conn(struct context *ctx, const char *hint, char *tls, int line);
10381039

10391040
/* acct.c */
10401041
void accounting(tac_session *, tac_pak_hdr *);

tac_plus-ng/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static void read_px(struct context_px *ctx, int cur)
639639
free(ctx);
640640
}
641641

642-
static void reject_conn(struct context *ctx, const char *hint, char *tls, int line)
642+
void reject_conn(struct context *ctx, const char *hint, char *tls, int line)
643643
{
644644
if (!hint)
645645
hint = "";
@@ -1463,7 +1463,7 @@ static void accept_control_common(int s, struct scm_data_accept_ext *sd_ext, soc
14631463

14641464
static int query_mavis_host(struct context *ctx, void (*f)(struct context *))
14651465
{
1466-
if(!ctx->host || ctx->host->try_mavis != TRISTATE_YES)
1466+
if (!ctx->host || ctx->host->try_mavis != TRISTATE_YES)
14671467
return 0;
14681468
if (!ctx->mavis_tried) {
14691469
ctx->mavis_tried = 1;

tac_plus-ng/packet.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,13 @@ void tac_read(struct context *ctx, int cur)
564564
if (config.rad_dict && ctx->hdroff > 0 && ctx->hdr.tac.version < TAC_PLUS_MAJOR_VER) {
565565
#ifdef WITH_SSL
566566
if (ctx->tls) {
567+
int ssl_version = SSL_version(ctx->tls);
568+
if (!(ctx->host->bug_compatibility & CLIENT_BUG_BAD_TLS_VERSION) && (!tls_ver_ok(ctx->tls_versions, ssl_version & 0xff))) {
569+
ctx->reset_tcp = BISTATE_YES;
570+
reject_conn(ctx, NULL, (char *) SSL_get_version(ctx->tls), __LINE__);
571+
return;
572+
}
567573
if (ctx->radius_1_1 == BISTATE_YES) {
568-
int ssl_version = SSL_version(ctx->tls);
569574
switch (ssl_version) {
570575
case TLS1_3_VERSION:
571576
case DTLS1_2_VERSION: // FIXME, is that fine for radius/1.1?
@@ -575,7 +580,7 @@ void tac_read(struct context *ctx, int cur)
575580
break;
576581
default:
577582
ctx->reset_tcp = BISTATE_YES;
578-
cleanup(ctx, cur);
583+
reject_conn(ctx, NULL, (char *) SSL_get_version(ctx->tls), __LINE__);
579584
return;
580585
}
581586
}
@@ -606,12 +611,12 @@ void tac_read(struct context *ctx, int cur)
606611
#ifdef WITH_SSL
607612
if (ctx->tls && ctx->use_tls) {
608613
#define S "radsec"
609-
static struct tac_key key = { .len = sizeof(S) - 1, .key = S };
614+
static struct tac_key key = {.len = sizeof(S) - 1,.key = S };
610615
#undef S
611616
ctx->key = &key;
612617
} else if (ctx->tls && ctx->use_dtls) {
613618
#define S "radius/dtls"
614-
static struct tac_key key = { .len = sizeof(S) - 1, .key = S };
619+
static struct tac_key key = {.len = sizeof(S) - 1,.key = S };
615620
#undef S
616621
ctx->key = &key;
617622
} else
@@ -634,6 +639,12 @@ void tac_read(struct context *ctx, int cur)
634639
CHECK_PROTOCOL(tacacs_tls, tacacs);
635640
ctx->aaa_protocol = S_tacacs_tls;
636641
int ssl_version = SSL_version(ctx->tls);
642+
if (!(ctx->host->bug_compatibility & CLIENT_BUG_BAD_TLS_VERSION)
643+
&& (!tls_ver_ok(ctx->tls_versions, ssl_version & 0xff) || ssl_version != TLS1_3_VERSION)) {
644+
ctx->reset_tcp = BISTATE_YES;
645+
reject_conn(ctx, NULL, (char *) SSL_get_version(ctx->tls), __LINE__);
646+
return;
647+
}
637648
switch (ssl_version) {
638649
case TLS1_2_VERSION:
639650
case TLS1_3_VERSION:
@@ -642,11 +653,6 @@ void tac_read(struct context *ctx, int cur)
642653
ssl_version = 0;
643654
break;
644655
}
645-
if (!(ctx->host->bug_compatibility & CLIENT_BUG_BAD_TLS_VERSION) && (!tls_ver_ok(ctx->tls_versions, ssl_version & 0xff) || ssl_version != TLS1_3_VERSION)) {
646-
ctx->reset_tcp = BISTATE_YES;
647-
cleanup(ctx, cur);
648-
return;
649-
}
650656
} else
651657
#endif
652658
{
@@ -1149,12 +1155,13 @@ void tac_write(struct context *ctx, int cur)
11491155

11501156
#define STR_TYPE(A) { A, sizeof(A) - 1}
11511157
static str_t types[] = {
1152-
STR_TYPE(""), // 0
1153-
STR_TYPE("authen"), // 1, TAC_PLUS_AUTHEN
1154-
STR_TYPE("author"), // 2, TAC_PLUS_AUTHOR
1155-
STR_TYPE("acct"), // 3, TAC_PLUS_ACCT
1156-
STR_TYPE("status"), // 4
1158+
STR_TYPE(""), // 0
1159+
STR_TYPE("authen"), // 1, TAC_PLUS_AUTHEN
1160+
STR_TYPE("author"), // 2, TAC_PLUS_AUTHOR
1161+
STR_TYPE("acct"), // 3, TAC_PLUS_ACCT
1162+
STR_TYPE("status"), // 4
11571163
};
1164+
11581165
#undef STR_TYPE
11591166

11601167
static tac_session *new_session(struct context *ctx, tac_pak_hdr *tac_hdr, rad_pak_hdr *radhdr)

0 commit comments

Comments
 (0)