-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Native SPKAC support #6330
Native SPKAC support #6330
Conversation
Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion. The following commiters were not found in the CLA:
You can fix all these things without opening another issue. Please see CONTRIBUTING.md for more information |
@jas- |
@jas- Assuming your remote's name to joyent/node is
I've edited your patch to work on latest master. Once this is done, ping me and it should be ready for merge. Also, if you haven't, please sign the CLA as noted above. |
@trevnorris how can I pay better attention to core API changes such as this in the future? I used the docs and current usage when creating a new branch based on master while tracking v.0.11.7-release and still missed that change. Thanks for all of your tips and assistance! |
@jas- |
@trevnorris That is good information. Again I appreciate your help. Should I close the other open issue for this PR? My old dev env got wiped out so I rebuilt it from scratch. Although I used the same branch name after forking node core it didn't update the existing PR. There is still quite a bit I need to learn about git. |
src/node_crypto.cc
Outdated
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.
s/String::New/FIXED_ONE_BYTE_STRING/
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.
Should I use the node_isolate
arg? (ie FIXED_ONE_BYTE_STRING(node_isolate, "Certificate")
)
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.
yes
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.
Fixed. Thanks.
src/node_crypto.cc
Outdated
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.
i = NETSCAPE_SPKI_verify(spki, pkey) > 0;
? Right now, VerifySpkac() returns true when NETSCAPE_SPKI_verify() returns -1.
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.
Doh! Fixed, thanks.
Last round of comments. If you fix these up, I'm pretty sure we're there. :-) |
src/node_crypto.h
Outdated
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.
Sorry, maybe I didn't make myself clear: the thing is that the len parameter is never < 0, right? So in that case it could (and arguably should) be an unsigned int. The bool return value was perfectly okay, I had no beef with that.
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.
Whoops, fixed. Thanks.
Thanks Jason, landed in 7f66e44. Feel like writing documentation for it? |
@bnoordhuis Sure, example app too? |
I'm very rarely getting garbage characters after the result. Added some logging in the test: console.error('%j', stripLineEndings(certificate.exportPublicKey(spkacValid).toString('utf8')));
console.error('%j', stripLineEndings(spkacPem.toString('utf8'))); and I see this:
|
@isaacs I have come across this in more extensive testing as well. @bnoordhuis I alleviated this problem using the I am trying to track this down in the OpenSSL libs, I believe it to be stemming from the |
@jas- Awesome, thanks for continuing to plug away on it. |
Implements new class 'Certificate' within crypto object for working with SPKAC's (signed public key & challenge) natively. bool Certificate::verifySpkac(buffer) buffer Certificate::exportPublicKey(buffer) buffer Certificate::exportChallenge(buffer)
@isaacs I think I may be it resolved, can you test? I am not seeing it now. Architecture: Node: It seems that using Ah OpenSSL how I love digging through your |
All tests are passing. I'm going to re-merge this and the docs fix. Nice job @jas-. |
@trevnorris No problem, hope it solves it. Perhaps I should put together a more robust test case? |
Was merged again in 7bf46ba |
Thanks! |
@isaacs, @bnoordhuis & @trevnorris I realize you have already merged this but as it is my first submission and I already feel like I made a few rookie mistakes and wanted a more robust test case I whipped this up based on SPKAC's generated from multiple private keys of various size as well as various hashing algorithms. Also I have been lurking on IRC as I wanted to ask if it would be a beneficial feature to generate new SPKAC (useful for OAuth server -> server auth cases) as well as certificate generation (CSR's come to mind). In any event, thanks for all of the pointers too. |
@jas- If you have a better test case, well, you know, we take patches. ;-) |
@bnoordhuis Fair enough. |
crypto: Native SPKAC support
Implements new class 'Certificate' within crypto object
for working with SPKAC's (signed public key & challenge)
natively.
bool Certificate::verifySpkac(buffer)
buffer Certificate::exportPublicKey(buffer)
buffer Certificate::exportChallenge(buffer)