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:
Evgeny committed 2026-04-24 00:16:30 +03:00
1 parent 3625a4e5d5
commit e39979bfac
12 files changed
+131 -10

No files matched your search

+10 -1
View File
@@ -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"