Uh oh!
There was an error while loading. Please reload this page.
src: fix crypto.privateEncrypt fails first time - #42793
Conversation
nodejs-github-bot
commented
Apr 20, 2022
Review requested:
|
crypto.privateEncrypt fails for the first time after crypto.generateKeyPairSync with certain parameters Because the error stack is not cleaned up when crypto.generateKeyPairSync exits. Fixes: nodejs#40814
tniessen
left a comment
There was a problem hiding this comment.
It would be interesting to know why some ciphers populate the OpenSSL error queue even though WritePrivateKey appears to succeed.
| @@ -0,0 +1,35 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
Please either rename this file to better match what it tests, or add the test case to an existing test file that tests key objects.
Also, please add a comment explaining that this is a regression test for #40814.
liuxingbaoyu
commented
Apr 20, 2022
indeed! I'm also interested in why the exception is populated. But I don't know about openssl and I didn't find relevant information on the documentation. I'll show the stack for anyone with experience to investigate in depth. Callstack: |
liuxingbaoyu
commented
Apr 20, 2022
Also, do we need to add an assertion or something? Once any method is called and the error is left, it is easy to affect other methods. |
nodejs-github-bot
commented
Apr 21, 2022
panva
commented
Apr 22, 2022
@liuxingbaoyu I believe there's a consistent failure when using linked OpenSSL 1.1.1 |
liuxingbaoyu
commented
Apr 23, 2022
This looks to be another problem with In openssl3, the error is cleared inside openssl, but not in openssl1.1.1. I don't know if this is a bug or a behavior change. Exception source: ERR_set_mark();ret=pem_read_bio_key_decoder(bp,x,ossl_pw_pem_password,&pwdata,libctx,propq,selection);if(ret==NULL&&(BIO_seek(bp,pos)<0||(ret=pem_read_bio_key_legacy(bp,x,ossl_pw_pem_password,&pwdata,libctx,propq,selection))==NULL))ERR_clear_last_mark();elseERR_pop_to_mark();node/src/crypto/crypto_keys.cc Lines 257 to 258 in 6b004f1 Also, does anyone know what's the reason here? |
aduh95
commented
Oct 28, 2022
Ping @nodejs/crypto for (re)reviews. |
nodejs-github-bot
commented
Oct 29, 2022
nodejs-github-bot
commented
Oct 29, 2022
Commit Queue failed- Loading data for nodejs/node/pull/42793
FetchError: Invalid response body while trying to fetch https://api.github.com/graphql: Premature close
at consumeBody (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/node_modules/node-fetch/src/body.js:234:60)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Response.text (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/node_modules/node-fetch/src/body.js:158:18)
at async Request.json (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/lib/request.js:51:18)
at async Request.query (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/lib/request.js:109:20)
at async Request.queryAll (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/lib/request.js:136:20)
at async Request.gql (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/lib/request.js:66:22)
at async PRData.getComments (file:///opt/hostedtoolcache/node/18.12.0/x64/lib/node_modules/node-core-utils/lib/pr_data.js:97:21)
at async Promise.all (index 2)
at async Promise.all (index 1) {
type: 'system',
errno: 'ERR_STREAM_PREMATURE_CLOSE',
code: 'ERR_STREAM_PREMATURE_CLOSE',
erroredSysCall: undefined
}https://github.com/nodejs/node/actions/runs/3352810353 |
aduh95
commented
Oct 29, 2022
Landed in e512786 |
`crypto.privateEncrypt` fails for the first time after `crypto.generateKeyPairSync` with certain parameters because the error stack is not cleaned up when `crypto.generateKeyPairSync` exits. Fixes: #40814 PR-URL: #42793 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
`crypto.privateEncrypt` fails for the first time after `crypto.generateKeyPairSync` with certain parameters because the error stack is not cleaned up when `crypto.generateKeyPairSync` exits. Fixes: #40814 PR-URL: #42793 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
`crypto.privateEncrypt` fails for the first time after `crypto.generateKeyPairSync` with certain parameters because the error stack is not cleaned up when `crypto.generateKeyPairSync` exits. Fixes: #40814 PR-URL: #42793 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
`crypto.privateEncrypt` fails for the first time after `crypto.generateKeyPairSync` with certain parameters because the error stack is not cleaned up when `crypto.generateKeyPairSync` exits. Fixes: #40814 PR-URL: #42793 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Fix crypto.privateEncrypt fails for the first time after crypto.generateKeyPairSync with certain parameters
Because the error stack is not cleaned up when crypto.generateKeyPairSync exits.
Fixes: #40814