-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
implement verifyFromStr #63
base: master
Are you sure you want to change the base?
Conversation
* upstream/master: test: update cert & chain for verify (Southern#62)
@lolBig may I ask you to use |
Morning - has there been any further progress on this one? My understanding is this addresses #42 ? Thank you |
include/x509.h
Outdated
|
||
Local<Value> try_parse(const std::string& dataString); | ||
Local<Value> verify(const std::string& dataString); | ||
Local<Value> verifyFromStr(const std::string& dataString); |
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.
Change to verify_from_str()
.
index.js
Outdated
try { | ||
x509.verifyFromStr(certStr, CABundleStr); | ||
} | ||
catch (verificationError) { |
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.
Move catch to previous line, please :)
index.js
Outdated
catch (verificationError) { | ||
caughtErr = verificationError; | ||
} | ||
finally { |
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.
Ditto.
index.js
Outdated
@@ -6,6 +6,19 @@ exports.getAltNames = x509.getAltNames; | |||
exports.getSubject = x509.getSubject; | |||
exports.getIssuer = x509.getIssuer; | |||
|
|||
exports.verifyFromStr = function(certStr, CABundleStr, cb) { |
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.
Valid if certStr
and CABundleStr
is a Buffer
or 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.
CABundleStr
should be caBundleStr
. It is not a constant, therefore it should not start with a capital.
X509_free(ca_cert); | ||
BIO_free_all(ca_bio); | ||
X509_free(cert); | ||
BIO_free_all(cert_bio); |
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.
Check store
, verify_ctx
and others is a NULL
, free a NULL
might cause segfault.
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.
these functions have checked NULL, the free function also does nothing when ptr is NULL , so we don't need to check again
README.md
Outdated
@@ -137,6 +137,21 @@ x509.verify( | |||
|
|||
``` | |||
|
|||
#### x509.verifyFromStr(`certStr`, `caStr`, function(err, result){ /*...*/}) |
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.
use CABundleStr
to replace caStr
to keep consistent with verify()
.
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.
CABundleStr
should be caBundleStr
. It is not a constant, therefore it should not start with a capital.
caughtErr = verificationError; | ||
} | ||
finally { | ||
cb(caughtErr); |
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.
Valid the callback is a function, too.
index.js
Outdated
@@ -6,6 +6,32 @@ exports.getAltNames = x509.getAltNames; | |||
exports.getSubject = x509.getSubject; | |||
exports.getIssuer = x509.getIssuer; | |||
|
|||
exports.verifyFromStr = function(certStr, CABundleStr, cb) { | |||
if (typeof cb !== 'function') { | |||
throw new Error('cb should be function') |
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.
Miss semi-colons in this file.
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.
LGTM
@lolBig The CI in node stable seems failed. |
@yorkie seems node-x509 can not make compatable with Node v10.7.0 |
@yorkie worked with Node v8.10.0 |
Ok, #71 fixes the problem, so I will merge this after it gets done :) |
README.md
Outdated
@@ -137,6 +137,21 @@ x509.verify( | |||
|
|||
``` | |||
|
|||
#### x509.verifyFromStr(`certStr`, `CABundleStr`, function(err, result){ /*...*/}) |
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.
As @Southern said at #63 (comment), please update the CABundleStr to caBundleStr
.
No description provided.