-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Crypto add opensslerror stack #15518
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f2c9e49
crypto: better crypto error messages
gla5001 dc2165a
Review updates and tests
gla5001 5c24f07
Additional review updates.
gla5001 d1296cf
Review update. Use the overload of Set()
gla5001 2b177cb
Nit fix: changing local variable to snake_case
gla5001 bbaea8b
PR review updates
gla5001 a5a2f64
changing openSSLErrorStack property name to opensslErrorStack
gla5001 2ad7440
fixing long doc line
gla5001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Additional review updates.
- Loading branch information
commit 5c24f07ab7f9081a6069d39e2e3c124d2adf4443
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,20 +262,16 @@ void ThrowCryptoError(Environment* env, | |
| ERR_error_string_n(err, errmsg, sizeof(errmsg)); | ||
| message = String::NewFromUtf8(env->isolate(), errmsg, | ||
| v8::NewStringType::kNormal) | ||
| .ToLocalChecked(); | ||
| .ToLocalChecked(); | ||
| } else { | ||
| message = String::NewFromUtf8(env->isolate(), default_message, | ||
| v8::NewStringType::kNormal) | ||
| .ToLocalChecked(); | ||
| .ToLocalChecked(); | ||
| } | ||
|
|
||
| Local<Value> exception_v = Exception::Error(message); | ||
| CHECK(!exception_v.IsEmpty()); | ||
| // Add the openSSLErrorStack property to the exception object. | ||
| Local<Object> exception = exception_v.As<Object>(); | ||
| Local<String> key = String::NewFromUtf8(env->isolate(), "openSSLErrorStack", | ||
| v8::NewStringType::kInternalized) | ||
| .ToLocalChecked(); | ||
| Local<Array> errorStack = Array::New(env->isolate()); | ||
|
|
||
| ERR_STATE *es = ERR_get_state(); | ||
|
|
@@ -289,17 +285,18 @@ void ThrowCryptoError(Environment* env, | |
| ERR_error_string_n(err_buf, tmpStr, sizeof(tmpStr)); | ||
| errorStack->Set(i, String::NewFromUtf8(env->isolate(), tmpStr, | ||
| v8::NewStringType::kNormal) | ||
| .ToLocalChecked()); | ||
| .ToLocalChecked()); | ||
| } | ||
|
Contributor
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. handle the ring buffer with modular arithmetic |
||
| es->top -= 1; | ||
| } | ||
|
|
||
| // Adding the new property that will look like the following: | ||
| // Add the openSSLErrorStack property to the exception object. | ||
| // The new property will look like the following: | ||
| // openSSLErrorStack: [ | ||
| // 'error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib', | ||
| // 'error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error' | ||
| // ] | ||
| exception->Set(env->context(), key, errorStack).FromJust(); | ||
| exception->Set(env->openssl_error_stack(), errorStack); | ||
| env->isolate()->ThrowException(exception); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,7 @@ assert.throws(function() { | |
| if ((err instanceof Error) && | ||
| /digest too big for rsa key$/.test(err) && | ||
| err.openSSLErrorStack !== undefined && | ||
| Array.isArray(err.openSSLErrorStack) && | ||
| err.openSSLErrorStack.length === 0) { | ||
| return true; | ||
|
Contributor
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. update test since the openSSLErrorStack is not always added |
||
| } | ||
|
|
@@ -265,6 +266,7 @@ assert.throws(function() { | |
| if ((err instanceof Error) && | ||
| /asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag/.test(err) && | ||
| err.openSSLErrorStack !== undefined && | ||
| Array.isArray(err.openSSLErrorStack) && | ||
| err.openSSLErrorStack.length > 0) { | ||
| return true; | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
This commit has the latest review comment fixes.
@bnoordhuis, i believe i've addressed all of your comments. Thanks for the review.