Skip to content

tls: TLSSocket options not initialized - #2614

Closed
jhamhader wants to merge 1 commit into
nodejs:masterfrom
jhamhader:tls-socket-default-options
Closed

tls: TLSSocket options not initialized#2614
jhamhader wants to merge 1 commit into
nodejs:masterfrom
jhamhader:tls-socket-default-options

Conversation

@jhamhader

Copy link
Copy Markdown
Contributor

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

@targostargos added the tls Issues and PRs related to the tls subsystem. label Aug 29, 2015
Comment threaddoc/api/tls.markdown Outdated

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@thefourtheye

Copy link
Copy Markdown
Contributor

If isServer is not set explicitly then it will be undefined. Does the code really check if the value is false anywhere?

Edit: I see that the code relies only on the truthiness/falsiness of isServer.

@jhamhader
jhamhaderforce-pushed the tls-socket-default-options branch 2 times, most recently from 9fc32cd to f61c44aCompareSeptember 19, 2015 12:17
@indutny

Copy link
Copy Markdown
Member

cc @nodejs/crypto

Comment threadlib/_tls_wrap.js Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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 isServerfalse by default - let's do it explicitly!

Copy link
Copy Markdown
ContributorAuthor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... sorry then!

@jhamhader
jhamhaderforce-pushed the tls-socket-default-options branch from f61c44a to 324bb28CompareSeptember 26, 2015 20:01
@jhamhader

Copy link
Copy Markdown
ContributorAuthor
  • Changed isServer to be false by default
  • Updated test to include two kinds of arguments of TLSSocket()

@jhamhader

Copy link
Copy Markdown
ContributorAuthor

@indutny can you confirm?

@indutny

Copy link
Copy Markdown
Member

Why is it needed? Would it be enough to do !!isServer when passing it to the C++ layer?

@jhamhader

Copy link
Copy Markdown
ContributorAuthor

Well, it is not only passed to the C++ layer - it is also used extensively in _tls_wrap.js.
Instead of the current change, we could do in TLSSocket():

this._tlsOptions.isServer = !!options.isServer

but initializing this value with a default boolean (in either way) seems like a harmless and safe thing to do.

@indutny

Copy link
Copy Markdown
Member

@jhamhader It feels like doing !! in one place is simpler.

@jhamhader
jhamhaderforce-pushed the tls-socket-default-options branch from 324bb28 to 7f69c59CompareOctober 20, 2015 19:06
@jhamhader

Copy link
Copy Markdown
ContributorAuthor

Done

Comment threaddoc/api/tls.markdown Outdated

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
ContributorAuthor

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
@jhamhader
jhamhaderforce-pushed the tls-socket-default-options branch from 7f69c59 to 62354f6CompareOctober 20, 2015 19:33
@indutny

Copy link
Copy Markdown
Member

LGTM

@indutny

Copy link
Copy Markdown
Member

@indutny

Copy link
Copy Markdown
Member

Landed in adfd20b, thank you!

@indutnyindutny closed this Oct 20, 2015
indutny pushed a commit that referenced this pull request Oct 20, 2015
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>
rvagg pushed a commit that referenced this pull request Oct 21, 2015
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>
@rvaggrvagg mentioned this pull request Oct 21, 2015
@MylesBorins

Copy link
Copy Markdown
Contributor

LTS?

@MylesBorins

Copy link
Copy Markdown
Contributor

/cc @jasnell

jasnell pushed a commit to jasnell/node that referenced this pull request Oct 26, 2015
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>
@jasnell

Copy link
Copy Markdown
Member

Landed in v4.x-staging in 590378c

jasnell pushed a commit that referenced this pull request Oct 26, 2015
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>
jasnell pushed a commit that referenced this pull request Oct 29, 2015
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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tlsIssues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@jhamhader@thefourtheye@indutny@MylesBorins@jasnell@mscdex@targos