Skip to content

Commit 1bc2671

Browse files
Hiroshi Hatakenourdouf
authored andcommitted
input: add TLS version and cipher config support
introduces `tls_min_version`, `tls_max_version`, and `tls_ciphers` fields to input instances. These options are parsed during config loading and applied during TLS initialization." Signed-off-by: Eduardo Silva <[email protected]>
1 parent 8263430 commit 1bc2671

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

include/fluent-bit/flb_input.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ struct flb_input_instance {
445445
char *tls_crt_file; /* Certificate */
446446
char *tls_key_file; /* Cert Key */
447447
char *tls_key_passwd; /* Cert Key Password */
448+
char *tls_min_version; /* Minimum protocol version of TLS */
449+
char *tls_max_version; /* Maximum protocol version of TLS */
450+
char *tls_ciphers; /* TLS ciphers */
448451

449452
struct mk_list *tls_config_map;
450453

src/flb_input.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,15 @@ int flb_input_set_property(struct flb_input_instance *ins,
596596
else if (prop_key_check("tls.key_passwd", k, len) == 0) {
597597
flb_utils_set_plugin_string_property("tls.key_passwd", &ins->tls_key_passwd, tmp);
598598
}
599+
else if (prop_key_check("tls.min_version", k, len) == 0) {
600+
flb_utils_set_plugin_string_property("tls.min_version", &ins->tls_min_version, tmp);
601+
}
602+
else if (prop_key_check("tls.max_version", k, len) == 0) {
603+
flb_utils_set_plugin_string_property("tls.max_version", &ins->tls_max_version, tmp);
604+
}
605+
else if (prop_key_check("tls.ciphers", k, len) == 0) {
606+
flb_utils_set_plugin_string_property("tls.ciphers", &ins->tls_ciphers, tmp);
607+
}
599608
#endif
600609
else if (prop_key_check("storage.type", k, len) == 0 && tmp) {
601610
/* Set the storage type */
@@ -742,6 +751,18 @@ void flb_input_instance_destroy(struct flb_input_instance *ins)
742751
flb_sds_destroy(ins->tls_key_passwd);
743752
}
744753

754+
if (ins->tls_min_version) {
755+
flb_sds_destroy(ins->tls_min_version);
756+
}
757+
758+
if (ins->tls_max_version) {
759+
flb_sds_destroy(ins->tls_max_version);
760+
}
761+
762+
if (ins->tls_ciphers) {
763+
flb_sds_destroy(ins->tls_ciphers);
764+
}
765+
745766
/* release the tag if any */
746767
flb_sds_destroy(ins->tag);
747768

@@ -1321,6 +1342,26 @@ int flb_input_init_all(struct flb_config *config)
13211342
flb_input_instance_destroy(ins);
13221343
return -1;
13231344
}
1345+
1346+
if (ins->tls_min_version != NULL || ins->tls_max_version != NULL) {
1347+
ret = flb_tls_set_minmax_proto(ins->tls, ins->tls_min_version, ins->tls_max_version);
1348+
if (ret != 0) {
1349+
flb_error("[input %s] error setting up minmax protocol version of TLS",
1350+
ins->name);
1351+
flb_input_instance_destroy(ins);
1352+
return -1;
1353+
}
1354+
}
1355+
1356+
if (ins->tls_ciphers != NULL) {
1357+
ret = flb_tls_set_ciphers(ins->tls, ins->tls_ciphers);
1358+
if (ret != 0) {
1359+
flb_error("[input %s] error setting up TLS ciphers up to TLSv1.2",
1360+
ins->name);
1361+
flb_input_instance_destroy(ins);
1362+
return -1;
1363+
}
1364+
}
13241365
}
13251366

13261367
return 0;

0 commit comments

Comments
 (0)