-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
crypto: better crypto error messages #14725
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
57b5b47
1c695af
ed9f9b5
a72d7e1
0538b25
cb44cd4
3f7813b
6ff521b
8c2eba0
2510500
6ccb9fe
da057db
c981483
a10856a
e13d1df
22ae8c0
c1fce1e
cb94905
b4b7ac6
d82e107
ddc16e5
c6e165b
694ef89
e202d85
e1c37b3
5976e0f
e55b7f3
bd6907b
9c3182e
31ce2c1
dc1996d
fca7e49
2ac7b43
35a526c
0dad97c
1aca135
dcc41fd
ad3d899
9d9552f
bf1ca8f
f68ab39
468110b
eb4940e
99a7799
5ee2d3e
a172b7c
6cfd773
ff16337
d38e643
b8d532c
ed2f347
688765a
cba206f
4ae0afb
290315a
be6d807
64616bb
a564c1e
8c8c90b
bdaa2cb
2509c34
1a0727d
7456db9
d195a06
92e5f5c
0c258bd
973c12f
e9358af
082c434
6bfc439
01652cc
f9ad23d
bac313b
e3f4305
8f52ccc
d8a0364
8bd1668
a591610
dce72c2
01a1812
8403d6b
dcb24e3
2e8217c
0fc402b
11f46a2
3c4c0db
a901849
ca2c73c
b0d3bec
631c59b
75f7b2f
9b996f0
bd85752
a4e923f
de51717
8fa5fcc
c75f87c
1976654
2b7b9f2
e86952d
1ebde6e
049a8d7
4dc920a
8a968e4
6f34076
faaefa8
a8c0a43
db2e093
4bcb1c3
b1c8f15
e167ab7
3c65a83
873e5bd
2f5bef4
8589c70
15879ad
784cdad
3070d53
c5eb5bf
10be20a
750c080
602fd36
87bddda
11f7dcf
6c38ab3
75606c4
ee46c73
6763fb2
01c680b
f27b5e4
4c19cef
84ea2b8
a83fc25
efa8086
c035ba0
720a5af
49f4f31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 { | ||
|
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. added additional space to these since its a continuation of line |
||
| 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()); | ||
| } | ||
| 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); | ||
| } | ||
|
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. new property looks like this
Contributor
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. Useful comment, please put it in the source code |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,6 +244,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; | ||
| } | ||
|
|
@@ -269,6 +270,7 @@ assert.throws(function() { | |
| if ((err instanceof Error) && | ||
| /asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag/.test(err) && | ||
| err.openSSLErrorStack !== undefined && | ||
|
Member
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. Maybe be more specific here and check |
||
| Array.isArray(err.openSSLErrorStack) && | ||
| err.openSSLErrorStack.length > 0) { | ||
| return true; | ||
| } | ||
|
|
||
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.
Can you name the property here?