EVPPKey does not fail if no password is set for a private key that requires a private key
EVPPKey does not fail if no password is set for a private key that requires a private key. Instead it goes to the default openssl callback routine which will prompt for the passphrase on the current terminal. The quote below is from the openssl man page for the PEM_read_bio_PrivateKey that is being used to read the private key.
If both cb and u are NULL then the default callback routine is used which will typically prompt for the passphrase on the current terminal with echoing turned off.
Is this the behavior that was intended? This breaks our application since the end user does not interact with a terminal.
The "fix" would be to not set pPassword to a nullptr in the case where pass is an empty string. https://github.com/pocoproject/poco/blob/191cbdc97e1d9de023b8a65e0dc844911c06f6a8/Crypto/include/Poco/Crypto/EVPPKey.h#L252-L254
That would be a breaking change - users who are currently not specifying the password and counting on the prompt, would (1) be unpleasantly surprised and (2) have no way to trigger the prompt. On the other hand, you can work around it by passing a bad password to trigger the exception - it may not be pretty, but it should do the job.
A proper solution would be to add a constructor and modify loadKey() to take callback argument - that way, user has full control of the behavior. If you are inclined to do the work, send a pull request to devel branch and we'll consider it for 1.13 release. Please make sure to also write a test case.
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 60 days since being marked as stale.