Skip to content

Commit 664aacd

Browse files
committed
input: Load CertStore with a user-defined store name
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 85d09ec commit 664aacd

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

include/fluent-bit/flb_input.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ struct flb_input_instance {
448448
char *tls_min_version; /* Minimum protocol version of TLS */
449449
char *tls_max_version; /* Maximum protocol version of TLS */
450450
char *tls_ciphers; /* TLS ciphers */
451+
#if defined(FLB_SYSTEM_WINDOWS)
452+
char *tls_win_certstore_name; /* CertStore Name (Windows) */
453+
#endif
451454

452455
struct mk_list *tls_config_map;
453456

src/flb_input.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ struct flb_config_map input_global_properties[] = {
123123
0, FLB_FALSE, 0,
124124
"Enable threading on an input"
125125
},
126+
{
127+
FLB_CONFIG_MAP_STR, "tls.windows.certstore_name", NULL,
128+
0, FLB_FALSE, 0,
129+
"Sets the certstore name on an input (Windows)"
130+
},
126131

127132
{0}
128133
};
@@ -391,6 +396,9 @@ struct flb_input_instance *flb_input_new(struct flb_config *config,
391396
instance->tls_crt_file = NULL;
392397
instance->tls_key_file = NULL;
393398
instance->tls_key_passwd = NULL;
399+
# if defined(FLB_SYSTEM_WINDOWS)
400+
instance->tls_win_certstore_name = NULL;
401+
# endif
394402
#endif
395403

396404
/* Plugin requires a co-routine context ? */
@@ -668,6 +676,11 @@ int flb_input_set_property(struct flb_input_instance *ins,
668676
else if (prop_key_check("tls.ciphers", k, len) == 0) {
669677
flb_utils_set_plugin_string_property("tls.ciphers", &ins->tls_ciphers, tmp);
670678
}
679+
# if defined(FLB_SYSTEM_WINDOWS)
680+
else if (prop_key_check("tls.windows.certstore_name", k, len) == 0 && tmp) {
681+
flb_utils_set_plugin_string_property("tls.windows.certstore_name", &ins->tls_win_certstore_name, tmp);
682+
}
683+
# endif
671684
#endif
672685
else if (prop_key_check("storage.type", k, len) == 0 && tmp) {
673686
/* Set the storage type */
@@ -826,6 +839,12 @@ void flb_input_instance_destroy(struct flb_input_instance *ins)
826839
flb_sds_destroy(ins->tls_ciphers);
827840
}
828841

842+
#if defined(FLB_SYSTEM_WINDOWS)
843+
if (ins->tls_win_certstore_name) {
844+
flb_sds_destroy(ins->tls_win_certstore_name);
845+
}
846+
#endif
847+
829848
/* release the tag if any */
830849
flb_sds_destroy(ins->tag);
831850

@@ -1260,6 +1279,26 @@ int flb_input_instance_init(struct flb_input_instance *ins,
12601279
return -1;
12611280
}
12621281
}
1282+
1283+
#if defined (FLB_SYSTEM_WINDOWS)
1284+
if (ins->tls_win_certstore_name) {
1285+
ret = flb_tls_set_certstore_name(ins->tls, ins->tls_win_certstore_name);
1286+
if (ret == -1) {
1287+
flb_error("[input %s] error specify certstore name in TLS context",
1288+
ins->name);
1289+
1290+
return -1;
1291+
}
1292+
1293+
ret = flb_tls_load_system_certificates(ins->tls);
1294+
if (ret == -1) {
1295+
flb_error("[input %s] error set up to load certstore with a user-defined name in TLS context",
1296+
ins->name);
1297+
1298+
return -1;
1299+
}
1300+
}
1301+
#endif
12631302
}
12641303

12651304
struct flb_config_map *m;

0 commit comments

Comments
 (0)