Repository navigation
Closed
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.staleIssues 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.
Description
📗 API Reference Docs Problem
- Version: v12.16.2
- Platform: Darwin Jacobs-MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
- Subsystem: crypto
Location
Section of the site where the content exists
Affected URL(s):
- https://nodejs.org/api/crypto.html#crypto_crypto_sign_algorithm_data_key
- https://nodejs.org/api/crypto.html#crypto_crypto_verify_algorithm_data_key_signature
- possibly (probably?) others
Description
Concise explanation of the problem
According to the documentation for crypto.sign and crypto.verify, the key argument may be a string, buffer, object, or KeyObject. It does not mention that if the key is a string or buffer, it must be pem format. Passing a key with der format will result in an error error:0909006C:PEM routines:get_name:no start line
The source code is quite clear that keys are assumed to be pem.
node/lib/internal/crypto/keys.js
Lines 277 to 280 in d6fe46f
| } else if (typeof key === 'string' || isArrayBufferView(key)) { | |
| // Expect PEM by default, mostly for backward compatibility. | |
| return { format: kKeyFormatPEM, data: key }; | |
| } else if (typeof key === 'object') { |
- I would like to work on this issue and
submit a pull request.
Metadata
Metadata
Assignees
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.staleIssues 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.
Activity
panva commentedon Nov 30, 2020
The docs do note
Then the
create*Keymethods do say thatPersonally 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.verifyTrott commentedon Dec 2, 2020
I 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?
github-actions commentedon Jun 27, 2026
This 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.
doc: clarify PEM format for signing keys
doc: clarify PEM format for signing keys
doc: clarify PEM format for signing keys
doc: clarify PEM format for signing keys
doc: clarify PEM format for signing keys