Skip to content
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

src: add .code and SSL specific error properties #25093

Closed
wants to merge 1 commit into from

Conversation

Projects
5 participants
@sam-github
Copy link
Member

commented Dec 17, 2018

SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a code
property, as well as the 3 string components of an SSL error: reason,
library, and function.

This is WIP, TBD is move the property strings to the isolate, and add docs and more tests.

I've seen a reasonable amount of code that is doing string matching on the error string, looking for the reason part, I think exposing the properties makes more sense. Also, I think the intention is for all Errors to expose .code properties for stable programmatic inspection.

I've gone some way to exposing these properties for node_crypto.cc, too, but I'm not done. Once this PR lands I'll keep working on it.

/to @nodejs/crypto

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Show resolved Hide resolved src/tls_wrap.cc Outdated
Show resolved Hide resolved src/tls_wrap.cc
@sam-github

This comment has been minimized.

Copy link
Member Author

commented Dec 18, 2018

@jasnell PTAL

@sam-github sam-github force-pushed the sam-github:tls-error-codes branch from 35dc539 to 18c6c1f Dec 20, 2018

@danbev

danbev approved these changes Dec 21, 2018

@danbev

This comment has been minimized.

Copy link
Member

commented Dec 21, 2018

@sam-github LGTM apart from I'm seeing the same test failures locally as reported by the CI run.

$ out/Release/node --tls-v1.1 /Users/danielbevenius/work/nodejs/node/test/parallel/test-tls-cli-min-version-1.1.js
assert.js:86
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ undefined
- 'ERR_SSL_VERSION_TOO_LOW'
    at common.mustCall (/Users/danielbevenius/work/nodejs/node/test/parallel/test-tls-min-max-version.js:31:14)
    at /Users/danielbevenius/work/nodejs/node/test/common/index.js:373:15
    at /Users/danielbevenius/work/nodejs/node/test/common/index.js:373:15
    at maybeCallback (/Users/danielbevenius/work/nodejs/node/test/fixtures/tls-connect.js:97:7)
    at Server.<anonymous> (/Users/danielbevenius/work/nodejs/node/test/fixtures/tls-connect.js:84:7)
    at Server.emit (events.js:188:13)
    at TLSSocket.onSocketTLSError (_tls_wrap.js:728:29)
    at TLSSocket.emit (events.js:188:13)
    at TLSSocket._tlsError (_tls_wrap.js:608:8)
    at TLSSocket.emit (events.js:188:13)
@addaleax
Copy link
Member

left a comment

LGTM with a comment

Show resolved Hide resolved src/tls_wrap.cc Outdated
src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

@sam-github sam-github force-pushed the sam-github:tls-error-codes branch from 18c6c1f to 04e841c Dec 27, 2018

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Dec 27, 2018

@danbev Oops, reordered the error number peek to after the error message long-form printf while addressing some comments, which doesn't work (printf clears the err number). Tests are passing again locally, lets see how CI does.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Dec 27, 2018

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Dec 27, 2018

Landed in ca9c0c9

@sam-github sam-github closed this Dec 27, 2018

@sam-github sam-github deleted the sam-github:tls-error-codes branch Dec 27, 2018

sam-github added a commit that referenced this pull request Dec 27, 2018

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: #25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@addaleax

This comment has been minimized.

Copy link
Member

commented Jan 5, 2019

Should this be backported to v11.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

sam-github added a commit to sam-github/node that referenced this pull request Jan 7, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Jan 7, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

Backport-PR-URL: https://github.com/nodejs/node/25376
PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@sam-github

This comment has been minimized.

Copy link
Member Author

commented Jan 7, 2019

Depends on #24729, semver-major, so not a backport candidate.

refack added a commit to refack/node that referenced this pull request Jan 14, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

@targos targos added this to Don't land (ever) in v11.x Jan 30, 2019

@sam-github sam-github referenced this pull request Mar 28, 2019

Closed

[v11.x backport] TLS1.3 #26951

3 of 4 tasks complete

sam-github added a commit to sam-github/node that referenced this pull request Mar 28, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Mar 28, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Mar 28, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Mar 29, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Apr 1, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Apr 8, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Apr 9, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Apr 9, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

sam-github added a commit to sam-github/node that referenced this pull request Apr 11, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

PR-URL: nodejs#25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

BethGriggs added a commit that referenced this pull request Apr 15, 2019

src: add .code and SSL specific error properties
SSL errors have a long structured message, but lacked the standard .code
property which can be used for stable comparisons. Add a `code`
property, as well as the 3 string components of an SSL error: `reason`,
`library`, and `function`.

Backport-PR-URL: #26951
PR-URL: #25093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

codebytere added a commit that referenced this pull request Apr 19, 2019

2019-04-23, Version 11.15.0 (Current)
* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

@codebytere codebytere referenced this pull request Apr 19, 2019

Merged

v11.15.0 proposal #27314

codebytere added a commit that referenced this pull request Apr 19, 2019

2019-04-23, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

codebytere added a commit that referenced this pull request Apr 19, 2019

2019-04-23, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

codebytere added a commit that referenced this pull request Apr 29, 2019

2019-04-23, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

codebytere added a commit to codebytere/node that referenced this pull request Apr 29, 2019

2019-04-30, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [nodejs#19794](nodejs#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [nodejs#25093](nodejs#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [nodejs#26951](nodejs#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [nodejs#26951](nodejs#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [nodejs#26951](nodejs#26951)
  * revert change to invalid protocol error type (Sam Roberts) [nodejs#26951](nodejs#26951)
  * support TLSv1.3 (Sam Roberts) [nodejs#26209](nodejs#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [nodejs#24729](nodejs#24729)

codebytere added a commit that referenced this pull request Apr 30, 2019

2019-04-30, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

PR-URL: #27314

codebytere added a commit that referenced this pull request Apr 30, 2019

2019-04-30, Version 11.15.0 (Current)
Notable changes:

* deps: add s390 asm rules for OpenSSL-1.1.1 (Shigeki Ohtsu) [#19794](#19794)
* src: add .code and SSL specific error properties (Sam Roberts) [#25093](#25093)
* tls:
  * add --tls-min-v1.2 CLI switch (Sam Roberts) [#26951](#26951)
  * supported shared openssl 1.1.0 (Sam Roberts) [#26951](#26951)
  * revert default max toTLSv1.2 (Sam Roberts) [#26951](#26951)
  * revert change to invalid protocol error type (Sam Roberts) [#26951](#26951)
  * support TLSv1.3 (Sam Roberts) [#26209](#26209)
  * add code for ERR\_TLS\_INVALID\_PROTOCOL\_METHOD (Sam Roberts) [#24729](#24729)

PR-URL: #27314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.