| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -215,7 +215,7 @@ function parsePrivateKeyEncoding(enc, keyType, objName) { | |||
| 215 | 215 | ||
| 216 | 216 | function getKeyObjectHandle(key, isPublic, allowKeyObject) { | |
| 217 | 217 | if (!allowKeyObject) { | |
| 218 | - return new ERR_INVALID_ARG_TYPE( | ||
| 218 | + throw new ERR_INVALID_ARG_TYPE( | ||
| 219 | 219 | 'key', | |
| 220 | 220 | ['string', 'Buffer', 'TypedArray', 'DataView'], | |
| 221 | 221 | key | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,6 +58,17 @@ const privatePem = fixtures.readSync('test_rsa_privkey.pem', 'ascii'); | |||
| 58 | 58 | assert(plaintext.equals(deciphered)); | |
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | + { | ||
| 62 | + // Passing an existing key object should throw. | ||
| 63 | + const publicKey = createPublicKey(publicPem); | ||
| 64 | + common.expectsError(() => createPublicKey(publicKey), { | ||
| 65 | + type: TypeError, | ||
| 66 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 67 | + message: 'The "key" argument must be one of type string, Buffer, ' + | ||
| 68 | + 'TypedArray, or DataView. Received type object' | ||
| 69 | + }); | ||
| 70 | + } | ||
| 71 | + | ||
| 61 | 72 | { | |
| 62 | 73 | const publicKey = createPublicKey(publicPem); | |
| 63 | 74 | assert.strictEqual(publicKey.type, 'public'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments