| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -730,7 +730,8 @@ existing server. Existing connections to the server are not interrupted. | |||
| 730 | 730 | added: v3.0.0 | |
| 731 | 731 | --> | |
| 732 | 732 | ||
| 733 | - * `keys` {Buffer} A 48-byte buffer containing the session ticket keys. | ||
| 733 | + * `keys` {Buffer|TypedArray|DataView} A 48-byte buffer containing the session | ||
| 734 | + ticket keys. | ||
| 734 | 735 | ||
| 735 | 736 | Sets the session ticket keys. | |
| 736 | 737 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1396,6 +1396,9 @@ Server.prototype.getTicketKeys = function getTicketKeys() { | |||
| 1396 | 1396 | ||
| 1397 | 1397 | ||
| 1398 | 1398 | Server.prototype.setTicketKeys = function setTicketKeys(keys) { | |
| 1399 | + validateBuffer(keys); | ||
| 1400 | + assert(keys.byteLength === 48, | ||
| 1401 | + 'Session ticket keys must be a 48-byte buffer'); | ||
| 1399 | 1402 | this._sharedCreds.context.setTicketKeys(keys); | |
| 1400 | 1403 | }; | |
| 1401 | 1404 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + if (!common.hasCrypto) { | ||
| 4 | + common.skip('missing crypto'); | ||
| 5 | + } | ||
| 6 | + | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const tls = require('tls'); | ||
| 9 | + | ||
| 10 | + const server = new tls.Server(); | ||
| 11 | + | ||
| 12 | + [null, undefined, 0, 1, 1n, Symbol(), {}, [], true, false, '', () => {}] | ||
| 13 | + .forEach((arg) => | ||
| 14 | + assert.throws( | ||
| 15 | + () => server.setTicketKeys(arg), | ||
| 16 | + { code: 'ERR_INVALID_ARG_TYPE' } | ||
| 17 | + )); | ||
| 18 | + | ||
| 19 | + [new Uint8Array(1), Buffer.from([1]), new DataView(new ArrayBuffer(2))].forEach( | ||
| 20 | + (arg) => | ||
| 21 | + assert.throws(() => { | ||
| 22 | + server.setTicketKeys(arg); | ||
| 23 | + }, /Session ticket keys must be a 48-byte buffer/) | ||
| 24 | + ); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments