*target = key;
return TRUE;
}
-
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "invalid string with keypair content");
return FALSE;
}
}
else if (obj->type == UCL_OBJECT) {
elt = ucl_object_find_key (obj, "pubkey");
if (elt == NULL || !ucl_object_tostring_safe (elt, &pk)) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "no sane pubkey found in the keypair");
return FALSE;
}
elt = ucl_object_find_key (obj, "privkey");
if (elt == NULL || !ucl_object_tostring_safe (elt, &sk)) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "no sane privkey found in the keypair");
return FALSE;
}
}
if (sk == NULL || pk == NULL) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "no sane pubkey or privkey found in the keypair");
return FALSE;
}
rspamd_snprintf (keybuf, sizeof (keybuf), "%*s%s", sem - sk, sk, pk);
}
- key = rspamd_http_connection_make_key (keybuf, strlen (val));
+ key = rspamd_http_connection_make_key (keybuf, strlen (keybuf));
if (key != NULL) {
/* XXX: clean buffer after usage */
*target = key;
return TRUE;
}
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "cannot load the keypair specified");
return FALSE;
}
GThreadPool *classify_pool;
/* Events base */
struct event_base *ev_base;
+ /* Encryption key */
+ gpointer key;
};
/*
new_task->classify_pool = ctx->classify_pool;
+ if (ctx->key) {
+ rspamd_http_connection_set_key (new_task->http_conn, ctx->key);
+ }
+
rspamd_http_connection_read_message (new_task->http_conn,
new_task,
nfd,
G_STRUCT_OFFSET (struct rspamd_worker_ctx,
classify_threads), RSPAMD_CL_FLAG_INT_32);
+
+ rspamd_rcl_register_worker_option (cfg, type, "keypair",
+ rspamd_rcl_parse_struct_keypair, ctx,
+ G_STRUCT_OFFSET (struct rspamd_worker_ctx,
+ key), 0);
+
return ctx;
}
g_mime_shutdown ();
rspamd_log_close (rspamd_main->logger);
+
+ if (ctx->key) {
+ rspamd_http_connection_key_destroy (ctx->key);
+ }
+
exit (EXIT_SUCCESS);
}