Skip to content

Commit

Permalink
crypto: fixup bug in keygen error handling
Browse files Browse the repository at this point in the history
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: #36779
Refs: #36729
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
jasnell authored and danielleadams committed Jan 12, 2021
1 parent 4c819d6 commit 42aca13
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/internal/crypto/keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ function generateKeyPairSync(type, options) {
}

function handleError(ret) {
if (ret === undefined)
if (ret == null)
return; // async

const [err, [publicKey, privateKey]] = ret;
const [err, keys] = ret;
if (err !== undefined)
throw err;

const [publicKey, privateKey] = keys;

// If no encoding was chosen, return key objects instead.
return {
publicKey: wrapKey(publicKey, PublicKeyObject),
Expand Down

0 comments on commit 42aca13

Please sign in to comment.