input: fixed the argument verification code so it properly handles input
plugins that establish outgoing connections.
@@ -841,7 +841,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;
+ int tls_session_mode;
if (ins->log_level == -1 && config->log != NULL) {
ins->log_level = config->log->level;
@@ -1015,22 +1015,34 @@ int flb_input_instance_init(struct flb_input_instance *ins,
}
#ifdef FLB_HAVE_TLS
- if (ins->use_tls == FLB_TRUE &&
- (p->flags & FLB_INPUT_NET_SERVER) != 0) {
+ if (ins->use_tls == FLB_TRUE) {
+ if ((p->flags & FLB_INPUT_NET_SERVER) != 0) {
if (ins->tls_crt_file == NULL) {
- tls_error_message = "certificate file missing";
+ flb_error("[input %s] error initializing TLS context "
+ "(certificate file missing)",
+ ins->name);
+
+ flb_input_instance_destroy(ins);
- ins->tls = NULL;
+ return -1;
}
else if (ins->tls_key_file == NULL) {
- tls_error_message = "private key file missing";
+ flb_error("[input %s] error initializing TLS context "
+ "(private key file missing)",
+ ins->name);
+
+ flb_input_instance_destroy(ins);
- ins->tls = NULL;
+ return -1;
+ }
+
+ tls_session_mode = FLB_TLS_SERVER_MODE;
}
else {
- tls_error_message = NULL;
+ tls_session_mode = FLB_TLS_CLIENT_MODE;
+ }
- ins->tls = flb_tls_create(FLB_TLS_SERVER_MODE,
+ ins->tls = flb_tls_create(tls_session_mode,
ins->tls_verify,
ins->tls_debug,
ins->tls_vhost,
@@ -1039,17 +1051,10 @@ 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);
