diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js index 2b0d58afd66..56f06f7a79f 100644 --- a/lib/internal/crypto/keygen.js +++ b/lib/internal/crypto/keygen.js @@ -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),