Repository navigation
tls: Add PSK support (v9.0.0-pre) #14978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fc041a8
9e188bc
51db277
09b9a8e
e954c49
caadeaf
45c120b
eef89b8
6f095f8
ba22b97
ba0727e
361b5ed
49a285f
16921ab
959887e
65cb351
7b43283
bbbb658
5136c93
6ed9f92
97a71bd
b810f97
92fc64e
4880511
40fae68
001b3bd
34e54c9
31fff46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
pskIdentity to pskIdentityHint. Updated errors to us…
…e the new error throwing format.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,7 +164,7 @@ exports.createSecureContext = function createSecureContext(options, context) { | |
|
|
||
| if (options.pskCallback && c.context.enablePskCallback) { | ||
| if (typeof options.pskCallback !== 'function') { | ||
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pskCallback', | ||
| throw new ERR_INVALID_ARG_TYPE('pskCallback', | ||
| 'function', options.pskCallback); | ||
| } | ||
|
|
||
|
|
@@ -178,19 +178,19 @@ exports.createSecureContext = function createSecureContext(options, context) { | |
| ret = { psk: ret.psk, identity: ret.identity }; | ||
|
|
||
| if (!typeof ret.psk === 'string') { | ||
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'psk', ['string']); | ||
| throw new ERR_INVALID_ARG_TYPE('psk', ['string']); | ||
| } | ||
| if (ret.psk.length / 2 > maxPskLen) { | ||
| throw new errors.RangeError( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the proper error to throw? There wasn't an existing error that satisfied the previous generic RangeError, so I just used
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, how is the formatting on these lines? It complies with eslint, but it's ugly as sin. |
||
| 'ERR_ASSERTION', | ||
| `Pre-shared key exceed ${maxPskLen} bytes` | ||
| `Pre-shared key exceeds ${maxPskLen} bytes` | ||
| ); | ||
| } | ||
|
|
||
| // Only set for the client callback, which must provide an identity. | ||
| if (maxIdentLen) { | ||
| if (typeof ret.identity !== 'string') { | ||
| throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'identity', | ||
| throw new ERR_INVALID_ARG_TYPE('identity', | ||
| 'string'); | ||
| } | ||
| if (ret.identity.length > maxIdentLen) { | ||
|
|
@@ -206,8 +206,8 @@ exports.createSecureContext = function createSecureContext(options, context) { | |
| }; | ||
| c.context.enablePskCallback(); | ||
|
|
||
| if (options.pskIdentity) | ||
| c.context.setPskIdentity(options.pskIdentity); | ||
| if (options.pskIdentityHint) | ||
| c.context.setPskIdentity(options.pskIdentityHint); | ||
| } | ||
|
|
||
| if (options.sessionIdContext) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking suggestion: I would prefer to call this
pskIdentityHint. Depending on the application, identity hints may use a different format than identities, and even if they use the same format, their values may differ.