You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
doc: crypto.sign and crypto.verify string/buffer keys must be pem #35331
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.
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*Key methods do say that
If 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, and Verify.prototype.verify
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?
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.
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.
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