Skip to content

Commit

Permalink
input: added missing mandatory TLS parameter detection and reporting.
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <leonardo@calyptia.com>
  • Loading branch information
leonardo-albertovich authored and edsiper committed Oct 19, 2022
1 parent 3000f69 commit fe6ca07
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ int flb_input_instance_init(struct flb_input_instance *ins,
struct flb_config *ctx = ins->config;
struct mk_list *config_map;
struct flb_input_plugin *p = ins->p;
const char *tls_error_message;

if (ins->log_level == -1 && config->log != NULL) {
ins->log_level = config->log->level;
Expand Down Expand Up @@ -1057,19 +1058,42 @@ int flb_input_instance_init(struct flb_input_instance *ins,

#ifdef FLB_HAVE_TLS
if (ins->use_tls == FLB_TRUE) {
ins->tls = flb_tls_create(FLB_TLS_SERVER_MODE,
ins->tls_verify,
ins->tls_debug,
ins->tls_vhost,
ins->tls_ca_path,
ins->tls_ca_file,
ins->tls_crt_file,
ins->tls_key_file,
ins->tls_key_passwd);
if (ins->tls_crt_file == NULL) {
tls_error_message = "certificate file missing";

ins->tls = NULL;
}
else if (ins->tls_key_file == NULL) {
tls_error_message = "private key file missing";

ins->tls = NULL;
}
else {
tls_error_message = NULL;

ins->tls = flb_tls_create(FLB_TLS_SERVER_MODE,
ins->tls_verify,
ins->tls_debug,
ins->tls_vhost,
ins->tls_ca_path,
ins->tls_ca_file,
ins->tls_crt_file,
ins->tls_key_file,
ins->tls_key_passwd);
}

if (ins->tls == NULL) {
flb_error("[input %s] error initializing TLS context",
ins->name);
if (tls_error_message != NULL) {
flb_error("[input %s] error initializing TLS context (%s)",
ins->name, tls_error_message);
}
else {
flb_error("[input %s] error initializing TLS context",
ins->name);
}

flb_input_instance_destroy(ins);

return -1;
}
}
Expand Down

0 comments on commit fe6ca07

Please sign in to comment.