Config: Added [allowed_keys] section for client public key authorization on server
- Added CFG_ALLOWED_KEY struct with binary key storage (64 bytes) for fast memcmp comparison - Implemented parsing of [allowed_keys] section with allow_all flag and per-key entries - Added key validation in etcp_connections.c server handler (errorcode=8 for rejected keys) - Default behavior: deny all if [allowed_keys] section is missing or allow_all=0 with no keys - Added proper memory cleanup and debug logging for allowed_keys configuration - Updated all test configs to include [allowed_keys] allow_all=1 for backward compatibility
This commit is contained in:
1 parent
3625a4e5d5
commit
e39979bfac
12 files changed
+131
-10
No files matched your search
@@ -95,7 +95,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:39011\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config: 2 subnets - 192.168.20.0/24 and 192.168.21.0/24
|
||||
static const char* client_config_content =
|
||||
|
||||
@@ -48,7 +48,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9021\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config content
|
||||
static const char* client_config_content =
|
||||
|
||||
@@ -55,7 +55,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9031\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config content (uses ports 9032)
|
||||
static const char* client_config_content =
|
||||
|
||||
@@ -39,7 +39,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server:test]\n"
|
||||
"addr=127.0.0.1:9011\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
static const char* client_config_content =
|
||||
"[global]\n"
|
||||
|
||||
@@ -67,7 +67,10 @@ static int create_temp_configs(void) {
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:%d\n"
|
||||
"type=public\n",
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n",
|
||||
server_port);
|
||||
fclose(f);
|
||||
|
||||
|
||||
@@ -48,7 +48,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9011\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config content
|
||||
static const char* client_config_content =
|
||||
|
||||
@@ -87,7 +87,10 @@ static int create_temp_configs(void) {
|
||||
"\n"
|
||||
"[server:test_s]\n"
|
||||
"addr=127.0.0.1:39011\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
if (write_config(config_s, tpl_s) != 0) return -1;
|
||||
if (config_ensure_keys_and_node_id(config_s) != 0) return -1;
|
||||
char* pub_s = get_pubkey_from_config(config_s);
|
||||
|
||||
@@ -52,7 +52,10 @@ static const char* server_config_content =
|
||||
"\n"
|
||||
"[server: test]\n"
|
||||
"addr=127.0.0.1:9041\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
|
||||
// Client config content (uses ports 9042 - unique to avoid conflicts)
|
||||
static const char* client_config_content =
|
||||
|
||||
+10
-1
@@ -87,7 +87,10 @@ static int create_temp_configs(void) {
|
||||
"\n"
|
||||
"[server:test_c]\n"
|
||||
"addr=127.0.0.1:39013\n"
|
||||
"type=public\n";
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n";
|
||||
if (write_config(config_c, tpl_c) != 0) return -1;
|
||||
if (config_ensure_keys_and_node_id(config_c) != 0) return -1;
|
||||
char* pub_c = get_pubkey_from_config(config_c);
|
||||
@@ -105,6 +108,9 @@ static int create_temp_configs(void) {
|
||||
"addr=127.0.0.1:39012\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n"
|
||||
"\n"
|
||||
"[client:to_c]\n"
|
||||
"keepalive=1\n"
|
||||
"peer_public_key=%s\n"
|
||||
@@ -128,6 +134,9 @@ static int create_temp_configs(void) {
|
||||
"addr=127.0.0.1:39011\n"
|
||||
"type=public\n"
|
||||
"\n"
|
||||
"[allowed_keys]\n"
|
||||
"allow_all=1\n"
|
||||
"\n"
|
||||
"[client:to_b]\n"
|
||||
"keepalive=1\n"
|
||||
"peer_public_key=%s\n"
|
||||
|
||||
Reference in new issue
Block a user