Suppress warnings about parsing Ed25519 keys when they are not present.

This commit is contained in:
Guus Sliepen 2015-02-16 08:42:30 +01:00
parent 833a8a048b
commit cffcaf966b
2 changed files with 11 additions and 3 deletions

View file

@ -84,11 +84,13 @@ static bool read_pem(FILE *fp, const char *type, void *buf, size_t size) {
size_t len = b64decode(line, line, linelen); size_t len = b64decode(line, line, linelen);
if(!len) { if(!len) {
logger(DEBUG_ALWAYS, LOG_ERR, "Invalid base64 data in PEM file\n"); logger(DEBUG_ALWAYS, LOG_ERR, "Invalid base64 data in PEM file\n");
errno = EINVAL;
return false; return false;
} }
if(len > size) { if(len > size) {
logger(DEBUG_ALWAYS, LOG_ERR, "Too much base64 data in PEM file\n"); logger(DEBUG_ALWAYS, LOG_ERR, "Too much base64 data in PEM file\n");
errno = EINVAL;
return false; return false;
} }
@ -98,7 +100,12 @@ static bool read_pem(FILE *fp, const char *type, void *buf, size_t size) {
} }
if(size) { if(size) {
logger(DEBUG_ALWAYS, LOG_ERR, "Too little base64 data in PEM file\n"); if(data) {
errno = EINVAL;
logger(DEBUG_ALWAYS, LOG_ERR, "Too little base64 data in PEM file\n");
} else {
errno = ENOENT;
}
return false; return false;
} }

View file

@ -137,10 +137,11 @@ bool read_ecdsa_public_key(connection_t *c) {
} }
c->ecdsa = ecdsa_read_pem_public_key(fp); c->ecdsa = ecdsa_read_pem_public_key(fp);
fclose(fp);
if(!c->ecdsa) if(!c->ecdsa && errno != ENOENT)
logger(DEBUG_ALWAYS, LOG_ERR, "Parsing Ed25519 public key file `%s' failed.", fname); logger(DEBUG_ALWAYS, LOG_ERR, "Parsing Ed25519 public key file `%s' failed.", fname);
fclose(fp);
free(fname); free(fname);
return c->ecdsa; return c->ecdsa;
} }