Skip to content

Commit

Permalink
incorrect fix for the extenion handling
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B. White <whitemat@uk.ibm.com>
  • Loading branch information
mbwhite committed Dec 19, 2018
1 parent e32709f commit caf6f7b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ addons:
language: node_js
node_js:
- "stable"
- "10"
- "8"
- "4.0"
- "0.12"
- "0.10"
Expand Down
8 changes: 5 additions & 3 deletions include/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@

// Include header for addon version, node/v8 inclusions, etc.
#include <addon.h>
#include <node_version.h>
#include <nan.h>
#include <node_version.h>
#include <string>

// OpenSSL headers
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/opensslv.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/x509_vfy.h>
#include <openssl/bn.h>
#include <openssl/x509v3.h>


using namespace v8;

Expand Down
9 changes: 3 additions & 6 deletions src/x509.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <x509.h>
#include <cstring>
#include <sstream>
#include <x509.h>


using namespace v8;

Expand Down Expand Up @@ -386,11 +387,7 @@ Local<Value> try_parse(const std::string& dataString) {
BIO *ext_bio = BIO_new(BIO_s_mem());
// IFNULL_FAIL(ext_bio, "unable to allocate memory for extension value BIO");
if (!X509V3_EXT_print(ext_bio, ext, 0, 0)) {
unsigned char *buf = NULL;
int len = i2d_ASN1_OCTET_STRING(X509_EXTENSION_get_data(ext), &buf);
if (len >= 0) {
BIO_write(ext_bio, static_cast<const void *>(buf), len);
}
ASN1_STRING_print(ext_bio, X509_EXTENSION_get_data(ext));
}

BUF_MEM *bptr;
Expand Down
13 changes: 13 additions & 0 deletions test/certs/certwithattrs.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB6TCCAY+gAwIBAgIUHkmY6fRP0ANTvzaBwKCkMZZPUnUwCgYIKoZIzj0EAwIw
GzEZMBcGA1UEAxMQZmFicmljLWNhLXNlcnZlcjAeFw0xNzA5MDgwMzQyMDBaFw0x
ODA5MDgwMzQyMDBaMB4xHDAaBgNVBAMTE015VGVzdFVzZXJXaXRoQXR0cnMwWTAT
BgcqhkjOPQIBBggqhkjOPQMBBwNCAATmB1r3CdWvOOP3opB3DjJnW3CnN8q1ydiR
dzmuA6A2rXKzPIltHvYbbSqISZJubsy8gVL6GYgYXNdu69RzzFF5o4GtMIGqMA4G
A1UdDwEB/wQEAwICBDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTYKLTAvJJK08OM
VGwIhjMQpo2DrjAfBgNVHSMEGDAWgBTEs/52DeLePPx1+65VhgTwu3/2ATAiBgNV
HREEGzAZghdBbmlscy1NYWNCb29rLVByby5sb2NhbDAmBggqAwQFBgcIAQQaeyJh
dHRycyI6eyJhdHRyMSI6InZhbDEifX0wCgYIKoZIzj0EAwIDSAAwRQIhAPuEqWUp
svTTvBqLR5JeQSctJuz3zaqGRqSs2iW+QB3FAiAIP0mGWKcgSGRMMBvaqaLytBYo
9v3hRt1r8j8vN0pMcg==
-----END CERTIFICATE-----
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ x509.verify(
function(err, result) {
assert.throws(assert.ifError.bind(null, err), /Failed to load cert/)
}
);
);

0 comments on commit caf6f7b

Please # to comment.