Skip to content

Commit a2373d5

Browse files
Hiroshi HatakeVanessa Zhang
authored andcommitted
output: support TLS version and cipher configuration
Adds support for `tls.min_version`, `tls.max_version`, and `tls.ciphers` in output instances. Values are parsed and enforced during TLS context setup. Signed-off-by: Eduardo Silva <[email protected]>
1 parent ee42457 commit a2373d5

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

include/fluent-bit/flb_output.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ struct flb_output_instance {
366366
char *tls_crt_file; /* Certificate */
367367
char *tls_key_file; /* Cert Key */
368368
char *tls_key_passwd; /* Cert Key Password */
369+
char *tls_min_version; /* Minimum protocol version of TLS */
370+
char *tls_max_version; /* Maximum protocol version of TLS */
371+
char *tls_ciphers; /* TLS ciphers */
369372
#endif
370373

371374
/*

src/flb_output.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ static void flb_output_free_properties(struct flb_output_instance *ins)
115115
if (ins->tls_key_passwd) {
116116
flb_sds_destroy(ins->tls_key_passwd);
117117
}
118+
if (ins->tls_min_version) {
119+
flb_sds_destroy(ins->tls_min_version);
120+
}
121+
if (ins->tls_max_version) {
122+
flb_sds_destroy(ins->tls_max_version);
123+
}
124+
if (ins->tls_ciphers) {
125+
flb_sds_destroy(ins->tls_ciphers);
126+
}
118127
#endif
119128
}
120129

@@ -907,6 +916,15 @@ int flb_output_set_property(struct flb_output_instance *ins,
907916
else if (prop_key_check("tls.key_passwd", k, len) == 0) {
908917
flb_utils_set_plugin_string_property("tls.key_passwd", &ins->tls_key_passwd, tmp);
909918
}
919+
else if (prop_key_check("tls.min_version", k, len) == 0) {
920+
flb_utils_set_plugin_string_property("tls.min_version", &ins->tls_min_version, tmp);
921+
}
922+
else if (prop_key_check("tls.max_version", k, len) == 0) {
923+
flb_utils_set_plugin_string_property("tls.max_version", &ins->tls_max_version, tmp);
924+
}
925+
else if (prop_key_check("tls.ciphers", k, len) == 0) {
926+
flb_utils_set_plugin_string_property("tls.ciphers", &ins->tls_ciphers, tmp);
927+
}
910928
#endif
911929
else if (prop_key_check("storage.total_limit_size", k, len) == 0 && tmp) {
912930
if (strcasecmp(tmp, "off") == 0 ||
@@ -1271,6 +1289,26 @@ int flb_output_init_all(struct flb_config *config)
12711289
return -1;
12721290
}
12731291
}
1292+
1293+
if (ins->tls_min_version != NULL || ins->tls_max_version != NULL) {
1294+
ret = flb_tls_set_minmax_proto(ins->tls, ins->tls_min_version, ins->tls_max_version);
1295+
if (ret != 0) {
1296+
flb_error("[output %s] error setting up minmax protocol version of TLS",
1297+
ins->name);
1298+
flb_output_instance_destroy(ins);
1299+
return -1;
1300+
}
1301+
}
1302+
1303+
if (ins->tls_ciphers != NULL) {
1304+
ret = flb_tls_set_ciphers(ins->tls, ins->tls_ciphers);
1305+
if (ret != 0) {
1306+
flb_error("[output %s] error setting up TLS ciphers up to TLSv1.2",
1307+
ins->name);
1308+
flb_output_instance_destroy(ins);
1309+
return -1;
1310+
}
1311+
}
12741312
}
12751313
#endif
12761314
/*

0 commit comments

Comments
 (0)