Repository navigation
doc: crypto.sign and crypto.verify string/buffer keys must be pem #35331
Description
Activity
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Sep 24, 2020 - addedcryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.
on Oct 26, 2020 The docs do note
If key is not a KeyObject, this function behaves as if key had been passed to crypto.createPrivateKey().
If key is not a KeyObject, this function behaves as if key had been passed to crypto.createPublicKey().
Then the
create*Keymethods do say thatIf key is a string or Buffer, format is assumed to be 'pem'
Personally i think this is clear and removes a lot of documentation duplication that would have to be in place if this was to be mentioned all repeated in
crypto.sign,crypto.verify,Sign.prototype.sign, andVerify.prototype.verifyI agree with the avoiding-duplication point. Still, if this is tripping up users, then I also wouldn't mind mentioning PEM. Maybe something like this?
If key is not a KeyObject, this function behaves as if key had been passed to crypto.createPublicKey(). For example, strings and buffers must be in PEM format.
github-actions commented
on Jun 27, 2026 on Jun 27, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jun 27, 2026 - added a commit that references this issue
on Jul 15, 2026 - added 2 commits that reference this issue
on Jul 21, 2026 - added a commit that references this issue
on Jul 29, 2026 - added a commit that references this issue
on Aug 6, 2026
📗 API Reference Docs Problem
Location
Section of the site where the content exists
Affected URL(s):
Description
Concise explanation of the problem
According to the documentation for
crypto.signandcrypto.verify, thekeyargument may be a string, buffer, object, orKeyObject. It does not mention that if the key is a string or buffer, it must bepemformat. Passing a key withderformat will result in an errorerror:0909006C:PEM routines:get_name:no start lineThe source code is quite clear that keys are assumed to be pem.
node/lib/internal/crypto/keys.js
Lines 277 to 280 in d6fe46f
submit a pull request.