dumpon: provide diag info when PEM_read_RSA_PUBKEY fails

This change modifies dumpon to print out the last error from OpenSSL
when `PEM_read_RSA_PUBKEY` fails. This allows end-users to diagnose why
reading in RSA pubkey files fails so they can adjust the usage to meet
the needs of the command.

MFC after:	1 week
This commit is contained in:
Enji Cooper 2023-05-26 18:02:34 -07:00
parent da8c3d2149
commit 52b63df9b6

View File

@ -270,7 +270,8 @@ _genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap)
fclose(fp);
fp = NULL;
if (pubkey == NULL)
errx(1, "Unable to read data from %s.", pubkeyfile);
errx(1, "Unable to read data from %s: %s", pubkeyfile,
ERR_error_string(ERR_get_error(), NULL));
/*
* RSA keys under ~1024 bits are trivially factorable (2018). OpenSSL