-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tls: TLSSocket options not initialized #2614
Conversation
@@ -460,7 +460,7 @@ Construct a new TLSSocket object from existing TCP socket. | |||
- `secureContext`: An optional TLS context object from | |||
`tls.createSecureContext( ... )` | |||
|
|||
- `isServer`: If true - TLS socket will be instantiated in server-mode | |||
- `isServer`: If true - TLS socket will be instantiated in server-mode. Default: `false` |
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.
The true
here should include backticks also for consistency.
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.
Done
If Edit: I see that the code relies only on the truthiness/falsiness of |
9fc32cd
to
f61c44a
Compare
cc @nodejs/crypto |
@@ -228,7 +228,7 @@ function initRead(tls, wrapped) { | |||
*/ | |||
|
|||
function TLSSocket(socket, options) { | |||
this._tlsOptions = options; | |||
this._tlsOptions = options || { isServer: false }; |
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.
I don't think that this can possibly suffice. There are also context and various other things that needs to be specified. It can't be possible to omit them, so I don't think that there is any point in providing this default values.
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.
If you would like to make isServer
false
by default - let's do it explicitly!
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.
I'll make isServer: false
by default (set to false
if options
is undefined
or options.isServer
is undefined
).
Regarding the context - TLS API says the rest of the options (besides isServer
) are optional and seems like _wrapHandle()
creates a secureContext
if such is not provided.
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.
Oh... sorry then!
f61c44a
to
324bb28
Compare
|
@indutny can you confirm? |
Why is it needed? Would it be enough to do |
Well, it is not only passed to the C++ layer - it is also used extensively in _tls_wrap.js.
but initializing this value with a default boolean (in either way) seems like a harmless and safe thing to do. |
@jhamhader It feels like doing |
324bb28
to
7f69c59
Compare
Done |
|
||
- `secureContext`: An optional TLS context object from | ||
`tls.createSecureContext( ... )` | ||
|
||
- `isServer`: If true - TLS socket will be instantiated in server-mode | ||
- `isServer`: If `true` - TLS socket will be instantiated in server-mode. Default: `false` |
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.
Is this over 80 column limit?
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.
Thanks for the thorough review. Fixed that
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options
7f69c59
to
62354f6
Compare
LGTM |
Landed in adfd20b, thank you! |
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options PR-URL: #2614 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options PR-URL: #2614 Reviewed-By: Fedor Indutny <fedor@indutny.com>
LTS? |
/cc @jasnell |
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options PR-URL: nodejs#2614 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Landed in v4.x-staging in 590378c |
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options PR-URL: #2614 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Upon creating a TLSSocket object, set the default isServer option to false Updated tls docs and added test-tls-socket-default-options PR-URL: #2614 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Upon creating a TLSSocket object without options, default options will be used, which
set the socket as isServer: false
Updated tls docs and added test-tls-socket-default-options
See issue #2394