size_t len = b64decode(line, line, linelen);
if(!len) {
logger(DEBUG_ALWAYS, LOG_ERR, "Invalid base64 data in PEM file\n");
+ errno = EINVAL;
return false;
}
if(len > size) {
logger(DEBUG_ALWAYS, LOG_ERR, "Too much base64 data in PEM file\n");
+ errno = EINVAL;
return false;
}
}
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;
}
}
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);
+
+ fclose(fp);
free(fname);
return c->ecdsa;
}