Skip to content

Attempting to load a passphrase-protected key should not prompt cin #4627

Open
@themightyoarfish

Description

@themightyoarfish

Describe the bug

Assuming a private key file protected by a password exists, it can be loaded with the EVPPkey constructor accepting empty pubkey name, private key name, and passphrase. If The passphrase is empty, the program will prompt the user to type in the key
with a message like Enter PEM pass phrase:. This is unsuitable for library code, since this cannot be reacted to unless the program is running in an interactive terminal.
It would be better to raise an exception, which happens e.g. when the wrong password is supplied.

To Reproduce

Attached an MVP with an encrypted openssl key

poco.zip

Expected behavior

Poco raises an exception when the key requires a passphrase, but none was supplied

Logs
n/a

Screenshots

CleanShot 2024-08-06 at 13 58 31

Please add relevant environment information:

  • OS Type and Version: macos ARM 12.7.5
  • POCO Version: 1.13.3 (homebrew)

Additional context

I know this probably comes from OpenSSL, but can this be worked around somehow?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions