Croak when passphrase is passed with DER-encoded key#176
Closed
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Closed
Croak when passphrase is passed with DER-encoded key#176toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
new_private_key() accepts @rest (passphrase) but _new_private_key_der() has no passphrase parameter, so the argument was silently dropped. Users expecting passphrase-protected DER loading got no indication it was ignored. Now croaks with a clear message instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
@toddr-bot would it not be better to add passphrase support to der-encoded keys |
Contributor
Author
toddr-bot
added a commit
to toddr-bot/Crypt-OpenSSL-RSA
that referenced
this pull request
Apr 23, 2026
_new_private_key_der() now accepts an optional passphrase to decrypt encrypted PKCS#8 DER (EncryptedPrivateKeyInfo) private keys. On OpenSSL 3.x, sets OSSL_DECODER_CTX_set_passphrase() on the existing decoder context. On pre-3.x, uses d2i_PKCS8PrivateKey_bio() via a helper placed before the EVP_PKEY->RSA compatibility macros. Addresses review feedback on PR cpan-authors#176 — rather than croaking when a passphrase is provided for DER keys, we now support the use case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
new_private_key()now croaks when a passphrase is provided for DER-encoded keys.Why
_new_private_key_der()has no passphrase parameter, so@restfrom the Perl wrapper was silently dropped. A user callingnew_private_key($der_key, "secret")would get no indication that the passphrase was ignored — a silent failure that could lead to incorrect security assumptions.How
Added a check for
@restin the DER branch ofnew_private_key(). If non-empty, croaks with"passphrase argument not supported for DER-encoded keys". This is consistent with how the module handles other invalid argument combinations.Testing
t/der.tverifying the croak message🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 8 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline