Skip to content

Commit fe10be5

Browse files
committed
output: Handle to load certificates with their thumbprints
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent baae91e commit fe10be5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/fluent-bit/flb_output.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ struct flb_output_instance {
374374
# if defined(FLB_SYSTEM_WINDOWS)
375375
char *tls_win_certstore_name; /* CertStore Name (Windows) */
376376
int tls_win_use_enterprise_certstore; /* Use enterprise CertStore */
377+
char *tls_win_thumbprints; /* CertStore Thumbprints (Windows) */
377378
# endif
378379
#endif
379380

src/flb_output.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ struct flb_config_map output_global_properties[] = {
9898
0, FLB_FALSE, 0,
9999
"Sets whether using enterprise certstore or not on an output (Windows)"
100100
},
101+
{
102+
FLB_CONFIG_MAP_STR, "tls.windows.client_thumbprints", NULL,
103+
0, FLB_FALSE, 0,
104+
"Comma-separated list of certificate thumbprints (SHA1/SHA256) to trust from the Windows store (Windows)"
105+
},
101106

102107
{0}
103108
};
@@ -193,6 +198,9 @@ static void flb_output_free_properties(struct flb_output_instance *ins)
193198
if (ins->tls_win_certstore_name) {
194199
flb_sds_destroy(ins->tls_win_certstore_name);
195200
}
201+
if (ins->tls_win_thumbprints) {
202+
flb_sds_destroy(ins->tls_win_thumbprints);
203+
}
196204
# endif
197205
#endif
198206
}
@@ -774,6 +782,7 @@ struct flb_output_instance *flb_output_new(struct flb_config *config,
774782
# if defined(FLB_SYSTEM_WINDOWS)
775783
instance->tls_win_certstore_name = NULL;
776784
instance->tls_win_use_enterprise_certstore = FLB_FALSE;
785+
instance->tls_win_thumbprints = NULL;
777786
# endif
778787
#endif
779788

@@ -1007,6 +1016,9 @@ int flb_output_set_property(struct flb_output_instance *ins,
10071016
ins->tls_win_use_enterprise_certstore = flb_utils_bool(tmp);
10081017
flb_sds_destroy(tmp);
10091018
}
1019+
else if (prop_key_check("tls.windows.client_thumbprints", k, len) == 0 && tmp) {
1020+
flb_utils_set_plugin_string_property("tls.windows.client_thumbprints", &ins->tls_win_thumbprints, tmp);
1021+
}
10101022
# endif
10111023
#endif
10121024
else if (prop_key_check("storage.total_limit_size", k, len) == 0 && tmp) {
@@ -1421,6 +1433,16 @@ int flb_output_init_all(struct flb_config *config)
14211433
}
14221434
}
14231435

1436+
if (ins->tls_win_thumbprints) {
1437+
ret = flb_tls_set_client_thumbprints(ins->tls, ins->tls_win_thumbprints);
1438+
if (ret == -1) {
1439+
flb_error("[input %s] error set up to use thumbprints of certificates in TLS context",
1440+
ins->name);
1441+
1442+
return -1;
1443+
}
1444+
}
1445+
14241446
if (ins->tls_win_certstore_name) {
14251447
flb_debug("[output %s] starting to load %s certstore in TLS context",
14261448
ins->name, ins->tls_win_certstore_name);

0 commit comments

Comments
 (0)