-
Notifications
You must be signed in to change notification settings - Fork 31.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
crypto: expose certificate decoding function #30675
Conversation
@@ -1153,7 +1153,6 @@ static void IsExtraRootCertsFileLoaded( | |||
return args.GetReturnValue().Set(extra_root_certs_loaded); | |||
} | |||
|
|||
|
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.
Unintended change?
I am not a big fan of this format, but I am afraid we might have to stick to it. |
@tniessen Can you think of a better name? So, a couple +'s, so I should finish this off? |
And yeah, I don't love the legacy format either, but its what we have until someone adds another. |
+1 to getting this in. For future changes, perhaps add an options argument that accepts a |
CHECK(args[0]->IsArrayBufferView()); | ||
ArrayBufferViewContents<unsigned char> buf(args[0].As<ArrayBufferView>()); | ||
const unsigned char* data = buf.data(); | ||
unsigned data_len = buf.length(); |
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.
Couple of width/sign issues here: buf.length()
returns a size_t
, d2i_X509
takes an int
. Suggestion:
size_t data_len = buf.length();
CHECK_LE(data_len, INT_MAX);
X509Pointer der(d2i_X509(nullptr, &data, data_len)); | ||
if (der) { | ||
args.GetReturnValue().Set(X509ToObject(env, der.get())); | ||
} |
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.
Style/local consistency: no braces, ditto on line 2219.
In general, I think JavaScript and Node.js are leaning towards verbosity, so I think |
Existing uses of |
8326473
to
8d8f6d1
Compare
8d8f6d1
to
2a14032
Compare
2a14032
to
70e7ec6
Compare
8ae28ff
to
2935f72
Compare
@sam-github did this get closed for any particular reason? It's not merged in yet, right? |
Format is the same as:
No docs or tests yet, @nodejs/crypto, I'll finish this if we want it.
Its easy, it just exposes current data format of the tls APIs, and makes testing whether certificates can be decoded quite easy, rather than having to round-trip them through TLS just to get a parsed cert :-(.
Maybe some other format would be better, and then it could be added to tls and crypto, but starting with a "better" format in crypto that is different from what tls does seems like it would increase inconsistency.
Fixes: #29181
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes