X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=a11f0060705158dbe7f048e8b185989abf51fada;hp=b46d1ae56096df27db4602aef0bf1b2bac391fa8;hb=ddea7a23a66b8fee4942f2ce237dcabe02e17270;hpb=23acc19bc090051156ad895caed61848f5afb144 diff --git a/src/net_setup.c b/src/net_setup.c index b46d1ae5..a11f0060 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -3,6 +3,7 @@ Copyright (C) 1998-2005 Ivo Timmermans, 2000-2010 Guus Sliepen 2006 Scott Lamb + 2010 Brandon Black This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,11 +113,14 @@ bool read_rsa_public_key(connection_t *c) { xasprintf(&fname, "%s/hosts/%s", confbase, c->name); fp = fopen(fname, "r"); - if(fp) { - c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); - fclose(fp); + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", fname, strerror(errno)); + free(fname); + return false; } + c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); + fclose(fp); free(fname); if(c->rsa_key) @@ -127,12 +131,15 @@ bool read_rsa_public_key(connection_t *c) { xasprintf(&fname, "%s/hosts/%s", confbase, c->name); fp = fopen(fname, "r"); - if(fp) { - c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); -// RSA_blinding_on(c->rsa_key, NULL); - fclose(fp); + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", fname, strerror(errno)); + free(fname); + return false; } + c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); +// RSA_blinding_on(c->rsa_key, NULL); + fclose(fp); free(fname); if(c->rsa_key) @@ -143,7 +150,7 @@ bool read_rsa_public_key(connection_t *c) { return false; } -bool read_rsa_private_key(void) { +static bool read_rsa_private_key(void) { FILE *fp; char *fname, *key, *pubkey; struct stat s; @@ -266,7 +273,7 @@ void load_all_subnets(void) { /* Configure node_t myself and set up the local sockets (listen only) */ -bool setup_myself(void) { +static bool setup_myself(void) { config_t *cfg; subnet_t *subnet; char *name, *hostname, *mode, *afname, *cipher, *digest;