Skip to content

Commit caf6f7b

Browse files
committed
incorrect fix for the extenion handling
Signed-off-by: Matthew B. White <whitemat@uk.ibm.com>
1 parent e32709f commit caf6f7b

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ addons:
1111
language: node_js
1212
node_js:
1313
- "stable"
14+
- "10"
15+
- "8"
1416
- "4.0"
1517
- "0.12"
1618
- "0.10"

include/x509.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33

44
// Include header for addon version, node/v8 inclusions, etc.
55
#include <addon.h>
6-
#include <node_version.h>
76
#include <nan.h>
7+
#include <node_version.h>
88
#include <string>
99

1010
// OpenSSL headers
1111
#include <openssl/asn1.h>
1212
#include <openssl/bio.h>
13+
#include <openssl/bn.h>
1314
#include <openssl/err.h>
15+
#include <openssl/opensslv.h>
1416
#include <openssl/pem.h>
1517
#include <openssl/x509.h>
16-
#include <openssl/x509v3.h>
1718
#include <openssl/x509_vfy.h>
18-
#include <openssl/bn.h>
19+
#include <openssl/x509v3.h>
20+
1921

2022
using namespace v8;
2123

src/x509.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include <x509.h>
12
#include <cstring>
23
#include <sstream>
3-
#include <x509.h>
4+
45

56
using namespace v8;
67

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

396393
BUF_MEM *bptr;

test/certs/certwithattrs.crt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIB6TCCAY+gAwIBAgIUHkmY6fRP0ANTvzaBwKCkMZZPUnUwCgYIKoZIzj0EAwIw
3+
GzEZMBcGA1UEAxMQZmFicmljLWNhLXNlcnZlcjAeFw0xNzA5MDgwMzQyMDBaFw0x
4+
ODA5MDgwMzQyMDBaMB4xHDAaBgNVBAMTE015VGVzdFVzZXJXaXRoQXR0cnMwWTAT
5+
BgcqhkjOPQIBBggqhkjOPQMBBwNCAATmB1r3CdWvOOP3opB3DjJnW3CnN8q1ydiR
6+
dzmuA6A2rXKzPIltHvYbbSqISZJubsy8gVL6GYgYXNdu69RzzFF5o4GtMIGqMA4G
7+
A1UdDwEB/wQEAwICBDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTYKLTAvJJK08OM
8+
VGwIhjMQpo2DrjAfBgNVHSMEGDAWgBTEs/52DeLePPx1+65VhgTwu3/2ATAiBgNV
9+
HREEGzAZghdBbmlscy1NYWNCb29rLVByby5sb2NhbDAmBggqAwQFBgcIAQQaeyJh
10+
dHRycyI6eyJhdHRyMSI6InZhbDEifX0wCgYIKoZIzj0EAwIDSAAwRQIhAPuEqWUp
11+
svTTvBqLR5JeQSctJuz3zaqGRqSs2iW+QB3FAiAIP0mGWKcgSGRMMBvaqaLytBYo
12+
9v3hRt1r8j8vN0pMcg==
13+
-----END CERTIFICATE-----

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ x509.verify(
5353
function(err, result) {
5454
assert.throws(assert.ifError.bind(null, err), /Failed to load cert/)
5555
}
56-
);
56+
);

0 commit comments

Comments
 (0)