X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_setup.c;h=c61a90122810719d924be949f5f46ea459859a2e;hb=e92b2004e20e1c8e6bc56f97bf4a45c6da4a630c;hp=cb14c5179fb3489c37e3a05abf16a166becf78ae;hpb=fc119fb0096a9221f2cff279b07c886bcd794d28;p=meshlink diff --git a/src/net_setup.c b/src/net_setup.c index cb14c517..c61a9012 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -223,6 +223,30 @@ static bool read_ecdsa_private_key(void) { return myself->connection->ecdsa; } +static bool read_invitation_key(void) { + FILE *fp; + char *fname; + + if(invitation_key) { + ecdsa_free(invitation_key); + invitation_key = NULL; + } + + xasprintf(&fname, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", confbase); + + fp = fopen(fname, "r"); + + if(fp) { + invitation_key = ecdsa_read_pem_private_key(fp); + fclose(fp); + if(!invitation_key) + logger(DEBUG_ALWAYS, LOG_ERR, "Reading ECDSA private key file `%s' failed: %s", fname, strerror(errno)); + } + + free(fname); + return invitation_key; +} + static bool read_rsa_private_key(void) { FILE *fp; char *fname; @@ -603,6 +627,8 @@ bool setup_myself_reloadable(void) { get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers); + read_invitation_key(); + return true; } @@ -912,8 +938,7 @@ static bool setup_myself(void) { free(address); if(err || !ai) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", - gai_strerror(err)); + logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", err == EAI_SYSTEM ? strerror(err) : gai_strerror(err)); return false; }