input: added missing mandatory TLS parameter detection and reporting.
@@ -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;
@@ -1057,6 +1058,19 @@ int flb_input_instance_init(struct flb_input_instance *ins,
#ifdef FLB_HAVE_TLS
if (ins->use_tls == FLB_TRUE) {
+ 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,
@@ -1066,10 +1080,20 @@ int flb_input_instance_init(struct flb_input_instance *ins,
ins->tls_crt_file,
ins->tls_key_file,
ins->tls_key_passwd);
+ }
+
if (ins->tls == NULL) {
+ 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;
}
}
