Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

implement verifyFromStr #63

wants to merge 12 commits into from

Conversation

qile222
Copy link
Contributor

@qile222 qile222 commented Dec 18, 2017

No description provided.

@yorkie
Copy link
Collaborator

yorkie commented Dec 18, 2017

@lolBig may I ask you to use Buffer instead of String, the former is in usual in Node.js ecosystem :)

@Budgiebrain994
Copy link

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);
Copy link
Collaborator

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) {
Copy link
Collaborator

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 {
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Owner

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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){ /*...*/})
Copy link
Collaborator

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().

Copy link
Owner

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);
Copy link
Collaborator

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')
Copy link
Collaborator

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.

Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yorkie
Copy link
Collaborator

yorkie commented Jul 27, 2018

@lolBig The CI in node stable seems failed.

@qile222
Copy link
Contributor Author

qile222 commented Jul 27, 2018

@yorkie seems node-x509 can not make compatable with Node v10.7.0

@qile222
Copy link
Contributor Author

qile222 commented Jul 27, 2018

@yorkie worked with Node v8.10.0

@yorkie
Copy link
Collaborator

yorkie commented Jul 28, 2018

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){ /*...*/})
Copy link
Collaborator

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants