Giter Site home page Giter Site logo

node-x509's Introduction

node-x509

Build Status

Simple X509 certificate parser.

Installation

From NPM (recommended): npm install x509

Building and testing from source:

sudo npm install -g node-gyp
npm install
npm test

Usage

Reading from a file:

const x509 = require('x509');
var issuer = x509.getIssuer(__dirname + '/certs/your.crt');

Reading from a string:

const fs = require('fs'),
      x509 = require('x509');
var issuer = x509.getIssuer(fs.readFileSync('./certs/your.crt').toString());

Methods

Notes:

  • cert may be a filename or a raw base64 encoded PEM string in any of these methods.

x509.getAltNames(cert)

Parse certificate with x509.parseCert and return the alternate names.

const x509 = require('x509');
var altNames = x509.getAltNames(__dirname + '/certs/nodejitsu.com.crt');
/*
altNames = [ '*.nodejitsu.com', 'nodejitsu.com' ]
*/

x509.getIssuer(cert)

Parse certificate with x509.parseCert and return the issuer.

const x509 = require('x509');
var issuer = x509.getIssuer(__dirname + '/certs/nodejitsu.com.crt');
/*
issuer = { countryName: 'GB',
  stateOrProvinceName: 'Greater Manchester',
  localityName: 'Salford',
  organizationName: 'COMODO CA Limited',
  commonName: 'COMODO High-Assurance Secure Server CA' }
*/

x509.getSubject(cert)

Parse certificate with x509.parseCert and return the subject.

const x509 = require('x509');
var subject = x509.getSubject(__dirname + '/certs/nodejitsu.com.crt');
/*
subject = { countryName: 'US',
  postalCode: '10010',
  stateOrProvinceName: 'NY',
  localityName: 'New York',
  streetAddress: '902 Broadway, 4th Floor',
  organizationName: 'Nodejitsu',
  organizationalUnitName: 'PremiumSSL Wildcard',
  commonName: '*.nodejitsu.com' }
*/

x509.parseCert(cert)

Parse subject, issuer, valid before and after date, and alternate names from certificate.

const x509 = require('x509');
var cert = x509.parseCert(__dirname + '/certs/nodejitsu.com.crt');
/*
cert = { subject:
   { countryName: 'US',
     postalCode: '10010',
     stateOrProvinceName: 'NY',
     localityName: 'New York',
     streetAddress: '902 Broadway, 4th Floor',
     organizationName: 'Nodejitsu',
     organizationalUnitName: 'PremiumSSL Wildcard',
     commonName: '*.nodejitsu.com' },
  issuer:
   { countryName: 'GB',
     stateOrProvinceName: 'Greater Manchester',
     localityName: 'Salford',
     organizationName: 'COMODO CA Limited',
     commonName: 'COMODO High-Assurance Secure Server CA' },
  notBefore: Sun Oct 28 2012 20:00:00 GMT-0400 (EDT),
  notAfter: Wed Nov 26 2014 18:59:59 GMT-0500 (EST),
  altNames: [ '*.nodejitsu.com', 'nodejitsu.com' ],
  signatureAlgorithm: 'sha1WithRSAEncryption',
  fingerPrint: 'E4:7E:24:8E:86:D2:BE:55:C0:4D:41:A1:C2:0E:06:96:56:B9:8E:EC',
  publicKey: {
    algorithm: 'rsaEncryption',
    e: '65537',
    n: '.......' } }
*/

x509.verify(cert, CABundlePath, function(err, result){ /.../})

Performs basic certificate validation against a bundle of ca certificates.

It accepts an error-first callback as first argument. If the error is null, then the certificate is valid.

The error messages are the same returned by openssl: x509_verify_cert_error_string

Note: As now, this function only accepts absolute paths to existing files as arguments

const x509 = require('x509');

x509.verify(
  __dirname + '/certs/user.com.crt',
  __dirname + 'enduser-example.com.chain',
  function(err, result){ /*...*/}
);

Examples

Checking the date to make sure the certificate is active:

const x509 = require('x509');
var cert = x509.parseCert('yourcert.crt'),
    date = new Date();

if (cert.notBefore > date) {
  // Certificate isn't active yet.
}
if (cert.notAfter < date) {
  // Certificate has expired.
}

License

MIT

Alternative implementation / build issues

If you are suffering from hard to fix build issues, there is an alternative (pure javascript) implementation using emscripten: https://github.com/encharm/x509.js (based on node-x509, slightly different API)

node-x509's People

Contributors

asilvas-godaddy avatar astitt-ripple avatar jcrugzz avatar lambrojos avatar mbwhite avatar mikelaspina avatar qile222 avatar rush avatar sonicdoe avatar southern avatar tanuck avatar yorkie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-x509's Issues

Unhandled rejection error

When I call parseCert with a wrong cert file like this parseCert('notreallyacrtfile.crt') I get

Unhandled rejection Error: Unable to parse certificate.
    at Error (native)

and I'm not able to catch that error.

trailing extra characters in cert extension subjectKeyIdentifier

Hi,

I was trying to use your node module for parsing a 509 certificate, pull the extension part of it and look for subjectKeyIdentifier value of it.

However, from time to time i am seeing extra trailing characters in that attribute, is it present in the cert itself or it is a bug ?

Problematic attribute:
"subjectKeyIdentifier":"86:12:8C:4C:0A:69:D6:0A:63:34:C9:C6:A7:76:10:FA:70:35:59:D4\u0002\u0001"

from logs:

-----BEGIN CERTIFICATE-----
MIIEoDCCAwigAwIBAgIETOX2GjANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJD
QTEbMBkGA1UECgwSQmxhY2tCZXJyeSBMaW1pdGVkMR4wHAYDVQQLDBVCbGFja0Jl
cnJ5IENpcnJ1cyBQS0kxMDAuBgNVBAMMJ0JsYWNrQmVycnkgQ2lycnVzIFJTQSBJ
bnRlcm1lZGlhdGUgQ0EgMTAeFw0xNTA0MTUxOTAwMDBaFw0zNDA3MDcxNzI1NTNa
MFoxCzAJBgNVBAYTAkNBMSEwHwYDVQQDExhBdkVOZVhsK2J4V2YyazRUWWk3UWVy
MD0xEzARBgNVBAsTCkVUUjYwNzU4NzMxEzARBgNVBAoTCjEyMzQ1Njc4OTAwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDChS0NECSlTzMeQ1MRC1OrnXIa
pBGWF6NXtLicaeJ7NS4ndV9MLaU0FMVwnN7C9E4cn7IIyoawVICR6jhgnTJPcMeu
30j8+I6AkjHLx0v+EGuyT2q7s9Dhqau0uo/nHurHP7ZUlH/60EKuNaTOTH8Gh0Os
XDPqPt7lzkTJrxEUg6V4l+1ocdKgfbmJQFFT2KdQ6t08+UPecxfrOHsOqMkDNkAt
jSWBOq7nl1RuUGje2x/hj1YePbhlGwIOdBE1Vx0hvHY0LEOsITpABmyxX/xhH29E
Rr51ANeur7o8TWEgNVD1/kSYR0l5uVH2hDnab/7SAAu0Cu3nQjAKE8ZKjAm1AgMB
AAGjgcswgcgwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCBLAwHQYDVR0OBBYE
FIYSjEwKadYKYzTJxqd2EPpwNVnUMB8GA1UdIwQYMBaAFHLDh4vCJ2JpnLSNlDqz
xYNgwtG3MFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9wa2kuc2VydmljZXMuYmxh
Y2tiZXJyeS5jb20vcHRvZS9yYS9jcmwvY2lycnVzLXJzYS1pY2EtMTAWBgNVHSUB
Af8EDDAKBggrBgEFBQcDAjANBgkqhkiG9w0BAQsFAAOCAYEASe5bINI6GJYcPu9q
n4Ayg50mLd+PZtj3UE/x+GBJ6ntghNVV+jKpwDSvbzeXND9rKX2t6XCaCc2LpKYM
o7O1mpElodI13QzTmNJVIN4cVvc6sSF4JD641ZYz8GdFqOK3ikK/sK8Lcqi7WcxK
zZl7IXbGWzkdn6Q/uTuOIZQY8wo7xppXO6ar7zqbZBZnnatzlWUO/VVuaXoF9NHj
kQDH9tc3zO9Y1RMHTnqlo0uvRbFDGT2DBB2j7/uSGem1t0ZN/6vqdrUkDeclRxB3
X9wgxVDmvNvkKLWC9+PdtqTzMCSQs/j5cX8ADDkHmc+o9WAg+g9vZ3Q8gw8edg84
J6tQ0dKZwC6sFNBzeXpFLFSTe4LRju43DRe7MILrJh2b3b/ttZkC/rBmU8LJkPEz
EpvUJGvpma+3Kk+yNFQ30DdEH4b+a3Xr6MaPKiXaKWZ4eH+3m+ABBATlsEaeilbd
1SXmEryiqWzorTrWgjjtoWcb/X8fcIP8zSPyuq6E8dnk1KDI
-----END CERTIFICATE-----

[2015-04-16T20:45:18.600Z] DEBUG: CERT PARSED : {"version":2,"subject":{"countryName":"CA","commonName":"AvENeXl+bxWf2k4TYi7Qer0=","organizationalUnitName":"ETR6075873","organizationName":"1234567890"},"issuer":{"countryName":"CA","organizationName":"BlackBerry Limited","organizationalUnitName":"BlackBerry Cirrus PKI","commonName":"BlackBerry Cirrus RSA Intermediate CA 1"},"serial":"4CE5F61A","notBefore":"2015-04-15T19:00:00.000Z","notAfter":"2034-07-07T17:25:53.000Z","signatureAlgorithm":"sha256WithRSAEncryption","fingerPrint":"44:2A:28:A3:63:01:4A:AC:E5:65:3E:7A:BA:BA:11:D4:99:90:4D:D6","publicKey":{"algorithm":"rsaEncryption","e":"65537","n":"C2852D0D1024A54F331E4353110B53AB9D721AA4119617A357B4B89C69E27B352E27755F4C2DA53414C5709CDEC2F44E1C9FB208CA86B0548091EA38609D324F70C7AEDF48FCF88E809231CBC74BFE106BB24F6ABBB3D0E1A9ABB4BA8FE71EEAC73FB654947FFAD042AE35A4CE4C7F068743AC5C33EA3EDEE5CE44C9AF111483A57897ED6871D2A07DB989405153D8A750EADD3CF943DE7317EB387B0EA8C90336402D8D25813AAEE797546E5068DEDB1FE18F561E3DB8651B020E741135571D21BC76342C43AC213A40066CB15FFC611F6F4446BE7500D7AEAFBA3C4D61203550F5FE4498474979B951F68439DA6FFED2000BB40AEDE742300A13C64A8C09B5"},"altNames":[],"extensions":{"basicConstraints":"CA:FALSE","keyUsage":"Digital Signature, Key Encipherment, Data Encipherment","subjectKeyIdentifier":"86:12:8C:4C:0A:69:D6:0A:63:34:C9:C6:A7:76:10:FA:70:35:59:D4\u0002\u0001","authorityKeyIdentifier":"keyid:72:C3:87:8B:C2:27:62:69:9C:B4:8D:94:3A:B3:C5:83:60:C2:D1:B7","cRLDistributionPoints":"\nFull Name:\n URI:http://pki.services.blackberry.com/ptoe/ra/crl/cirrus-rsa-ica-1","extendedKeyUsage":"TLS Web Client Authentication"}} (topic=applog, ecosystem=dev, system_scope=true, service_scope=true, requestId=034af50b-ae8b-472b-8c7c-66b30786b4b6)

Bump version of nan

Hi,

Currently, this package doesn't work with node v6.x because the version of nan is not compatible, the compilation will exit because of a missing named type in v8::Isolate

Bumping nan to v2.2.0 fixed the problem. I can create a pr if you wish?

Regards

travis-ci install error on node v4.2 and v5.5

For some reason travis-ci is unable to install node-x509 on some versions of node. Although they seem to work fine when I'm building locally. I'm wondering if you have any idea what's going on?

Here's the output node-gyp rebuild

> [email protected] install /home/travis/build/nickclaw/alexa-ability-express-handler/node_modules/x509
> node-gyp rebuild
make: Entering directory `/home/travis/build/nickclaw/alexa-ability-express-handler/node_modules/x509/build'
  CXX(target) Release/obj.target/x509/src/addon.o
In file included from /home/travis/.node-gyp/4.2.6/include/node/node.h:42:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/travis/.node-gyp/4.2.6/include/node/v8.h:336:1: error: expected unqualified-id before โ€˜usingโ€™
/home/travis/.node-gyp/4.2.6/include/node/v8.h:469:1: error: expected unqualified-id before โ€˜usingโ€™
/home/travis/.node-gyp/4.2.6/include/node/v8.h:852:1: error: expected unqualified-id before โ€˜usingโ€™
In file included from ../src/addon.cc:4:0:
../include/addon.h:9:11: error: variable or field โ€˜initโ€™ declared void
../include/addon.h:9:11: error: โ€˜Handleโ€™ was not declared in this scope
../include/addon.h:9:24: error: expected primary-expression before โ€˜>โ€™ token
../include/addon.h:9:26: error: โ€˜exportsโ€™ was not declared in this scope
In file included from ../node_modules/nan/nan.h:182:0,
                 from ../include/x509.h:7,
                 from ../src/addon.cc:5:
../node_modules/nan/nan_maybe_43_inl.h:13:1: error: expected unqualified-id before โ€˜usingโ€™
../node_modules/nan/nan_maybe_43_inl.h:16:1: error: expected unqualified-id before โ€˜usingโ€™
In file included from ../src/addon.cc:5:0:
../include/x509.h:27:1: error: โ€˜Handleโ€™ does not name a type
../include/x509.h:28:1: error: โ€˜Handleโ€™ does not name a type
../include/x509.h:29:1: error: โ€˜Handleโ€™ does not name a type
../include/x509.h:30:1: error: โ€˜Handleโ€™ does not name a type
../src/addon.cc:9:11: error: variable or field โ€˜initโ€™ declared void
../src/addon.cc:9:11: error: โ€˜Handleโ€™ was not declared in this scope
../src/addon.cc:9:24: error: expected primary-expression before โ€˜>โ€™ token
../src/addon.cc:9:26: error: โ€˜exportsโ€™ was not declared in this scope
../src/addon.cc:27:1: error: โ€˜initโ€™ was not declared in this scope
make: *** [Release/obj.target/x509/src/addon.o] Error 1
make: Leaving directory `/home/travis/build/nickclaw/alexa-ability-express-handler/node_modules/x509/build'

Accept string input

Hi,

It would be great if the library accepted string input in addition to file input. In my current use case I have to create a temporary file to use the lib. I am converting a file containing certificates into JSON so my data is already in string format.

Unable to Install v0.10.26

I can't seem to get x509 to install.
I've tried installing the sudo npm install -g node-gyp as well as npm install x509.
When I tried to install via node-gyp it seems to install correctly, but when I require('x509'); it says x509 doesn't exist.

Below are the errors I receive when trying to install with npm install x509:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'x509' ]
2 info using [email protected]
3 info using [email protected]
4 warn package.json [email protected] No repository field.
5 warn package.json [email protected] No README data
6 warn package.json [email protected] No repository field.
7 warn package.json [email protected] crypto is also the name of a node core module.
8 verbose readDependencies using package.json deps
9 verbose cache add [ 'x509', null ]
10 verbose cache add name=undefined spec="x509" args=["x509",null]
11 verbose parsed url { protocol: null,
11 verbose parsed url   slashes: null,
11 verbose parsed url   auth: null,
11 verbose parsed url   host: null,
11 verbose parsed url   port: null,
11 verbose parsed url   hostname: null,
11 verbose parsed url   hash: null,
11 verbose parsed url   search: null,
11 verbose parsed url   query: null,
11 verbose parsed url   pathname: 'x509',
11 verbose parsed url   path: 'x509',
11 verbose parsed url   href: 'x509' }
12 silly makeCacheDir cache dir uid, gid [ 0, 0 ]
13 silly lockFile 0b48d5df-x509 x509
14 verbose lock x509 /root/.npm/0b48d5df-x509.lock
15 silly lockFile 0b48d5df-x509 x509
16 silly lockFile 0b48d5df-x509 x509
17 verbose addNamed [ 'x509', '' ]
18 verbose addNamed [ null, '*' ]
19 silly lockFile a632de90-x509 x509@
20 verbose lock x509@ /root/.npm/a632de90-x509.lock
21 silly addNameRange { name: 'x509', range: '*', hasData: false }
22 verbose url raw x509
23 verbose url resolving [ 'https://registry.npmjs.org/', './x509' ]
24 verbose url resolved https://registry.npmjs.org/x509
25 info trying registry request attempt 1 at 03:18:46
26 http GET https://registry.npmjs.org/x509
27 http 200 https://registry.npmjs.org/x509
28 silly registry.get cb [ 200,
28 silly registry.get   { date: 'Wed, 19 Feb 2014 08:18:48 GMT',
28 silly registry.get     server: 'CouchDB/1.5.0 (Erlang OTP/R16B)',
28 silly registry.get     etag: '"DCX5XAL042KFKV85HREOX050B"',
28 silly registry.get     'content-type': 'application/json',
28 silly registry.get     via: '1.1 varnish',
28 silly registry.get     'cache-control': 'max-age=1',
28 silly registry.get     'content-length': '41425',
28 silly registry.get     'accept-ranges': 'bytes',
28 silly registry.get     age: '0',
28 silly registry.get     'x-served-by': 'cache-v43-ASH, cache-at52-ATL',
28 silly registry.get     'x-cache': 'MISS, MISS',
28 silly registry.get     'x-cache-hits': '0, 0',
28 silly registry.get     'x-timer': 'S1392797927.960889816,VS0,VS5,VE348,VE357',
28 silly registry.get     vary: 'Accept',
28 silly registry.get     'keep-alive': 'timeout=10, max=50',
28 silly registry.get     connection: 'Keep-Alive' } ]
29 silly addNameRange number 2 { name: 'x509', range: '*', hasData: true }
30 silly addNameRange versions [ 'x509',
30 silly addNameRange   [ '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7' ] ]
31 verbose addNamed [ 'x509', '0.0.7' ]
32 verbose addNamed [ '0.0.7', '0.0.7' ]
33 silly lockFile 6b107ce7-x509-0-0-7 [email protected]
34 verbose lock [email protected] /root/.npm/6b107ce7-x509-0-0-7.lock
35 silly lockFile 5ada6c56-ry-npmjs-org-x509-x509-0-0-7-tgz https://registry.npmjs.org/x509/-/x509-0.0.7.tgz
36 verbose lock https://registry.npmjs.org/x509/-/x509-0.0.7.tgz /root/.npm/5ada6c56-ry-npmjs-org-x509-x509-0-0-7-tgz.lock
37 verbose addRemoteTarball [ 'https://registry.npmjs.org/x509/-/x509-0.0.7.tgz',
37 verbose addRemoteTarball   '198a57a9691649b030a383e0e5f89e635d6e99e7' ]
38 info retry fetch attempt 1 at 03:18:48
39 verbose fetch to= /root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz
40 http GET https://registry.npmjs.org/x509/-/x509-0.0.7.tgz
41 http 200 https://registry.npmjs.org/x509/-/x509-0.0.7.tgz
42 verbose tar unpack /root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz
43 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
44 verbose lock tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package /root/.npm/e04e7ac0-8397-0-03312862361781299-package.lock
45 silly lockFile d0b30ba7-8397-0-03312862361781299-tmp-tgz tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz
46 verbose lock tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz /root/.npm/d0b30ba7-8397-0-03312862361781299-tmp-tgz.lock
47 silly gunzTarPerm modes [ '755', '644' ]
48 silly gunzTarPerm extractEntry package.json
49 silly gunzTarPerm extractEntry .npmignore
50 silly gunzTarPerm extractEntry README.md
51 silly gunzTarPerm extractEntry .travis.yml
52 silly gunzTarPerm extractEntry binding.gyp
53 silly gunzTarPerm extractEntry build/Makefile
54 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/addon.o.d
55 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/x509.o.d
56 silly gunzTarPerm extractEntry build/Release/.deps/Release/x509.node.d
57 silly gunzTarPerm extractEntry build/Release/linker.lock
58 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/addon.o
59 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/x509.o
60 silly gunzTarPerm extractEntry build/Release/x509.node
61 silly gunzTarPerm extractEntry build/binding.Makefile
62 silly gunzTarPerm extractEntry build/config.gypi
63 silly gunzTarPerm extractEntry build/gyp-mac-tool
64 silly gunzTarPerm extractEntry build/x509.target.mk
65 silly gunzTarPerm extractEntry include/addon.h
66 silly gunzTarPerm extractEntry include/x509.h
67 silly gunzTarPerm extractEntry src/addon.cc
68 silly gunzTarPerm extractEntry src/x509.cc
69 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
70 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
71 silly lockFile d0b30ba7-8397-0-03312862361781299-tmp-tgz tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz
72 silly lockFile d0b30ba7-8397-0-03312862361781299-tmp-tgz tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/tmp.tgz
73 verbose tar pack [ '/root/.npm/x509/0.0.7/package.tgz',
73 verbose tar pack   '/root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package' ]
74 verbose tarball /root/.npm/x509/0.0.7/package.tgz
75 verbose folder /root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
76 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
77 verbose lock tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package /root/.npm/e04e7ac0-8397-0-03312862361781299-package.lock
78 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
79 verbose lock tar:///root/.npm/x509/0.0.7/package.tgz /root/.npm/9ba0da1a--root-npm-x509-0-0-7-package-tgz.lock
80 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
81 silly lockFile e04e7ac0-8397-0-03312862361781299-package tar:///root/tmp/npm-29085-x3WzvcaD/1392797928397-0.03312862361781299/package
82 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
83 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
84 silly lockFile c583609c-root-npm-x509-0-0-7-package /root/.npm/x509/0.0.7/package
85 verbose lock /root/.npm/x509/0.0.7/package /root/.npm/c583609c-root-npm-x509-0-0-7-package.lock
86 silly lockFile c583609c-root-npm-x509-0-0-7-package /root/.npm/x509/0.0.7/package
87 silly lockFile c583609c-root-npm-x509-0-0-7-package /root/.npm/x509/0.0.7/package
88 verbose tar unpack /root/.npm/x509/0.0.7/package.tgz
89 silly lockFile 44586890-tar-root-npm-x509-0-0-7-package tar:///root/.npm/x509/0.0.7/package
90 verbose lock tar:///root/.npm/x509/0.0.7/package /root/.npm/44586890-tar-root-npm-x509-0-0-7-package.lock
91 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
92 verbose lock tar:///root/.npm/x509/0.0.7/package.tgz /root/.npm/9ba0da1a--root-npm-x509-0-0-7-package-tgz.lock
93 silly gunzTarPerm modes [ '755', '644' ]
94 silly gunzTarPerm extractEntry package.json
95 silly gunzTarPerm extractEntry .npmignore
96 silly gunzTarPerm extractEntry README.md
97 silly gunzTarPerm extractEntry .travis.yml
98 silly gunzTarPerm extractEntry binding.gyp
99 silly gunzTarPerm extractEntry build/Makefile
100 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/addon.o.d
101 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/x509.o.d
102 silly gunzTarPerm extractEntry build/Release/.deps/Release/x509.node.d
103 silly gunzTarPerm extractEntry build/Release/linker.lock
104 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/addon.o
105 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/x509.o
106 silly gunzTarPerm extractEntry build/Release/x509.node
107 silly gunzTarPerm extractEntry build/binding.Makefile
108 silly gunzTarPerm extractEntry build/config.gypi
109 silly gunzTarPerm extractEntry build/gyp-mac-tool
110 silly gunzTarPerm extractEntry build/x509.target.mk
111 silly gunzTarPerm extractEntry include/addon.h
112 silly gunzTarPerm extractEntry include/x509.h
113 silly gunzTarPerm extractEntry src/addon.cc
114 silly gunzTarPerm extractEntry src/x509.cc
115 silly lockFile 44586890-tar-root-npm-x509-0-0-7-package tar:///root/.npm/x509/0.0.7/package
116 silly lockFile 44586890-tar-root-npm-x509-0-0-7-package tar:///root/.npm/x509/0.0.7/package
117 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
118 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
119 verbose chmod /root/.npm/x509/0.0.7/package.tgz 644
120 verbose chown /root/.npm/x509/0.0.7/package.tgz [ 0, 0 ]
121 silly lockFile 5ada6c56-ry-npmjs-org-x509-x509-0-0-7-tgz https://registry.npmjs.org/x509/-/x509-0.0.7.tgz
122 silly lockFile 5ada6c56-ry-npmjs-org-x509-x509-0-0-7-tgz https://registry.npmjs.org/x509/-/x509-0.0.7.tgz
123 silly lockFile 6b107ce7-x509-0-0-7 [email protected]
124 silly lockFile 6b107ce7-x509-0-0-7 [email protected]
125 silly lockFile a632de90-x509 x509@
126 silly lockFile a632de90-x509 x509@
127 silly resolved [ { name: 'x509',
127 silly resolved     version: '0.0.7',
127 silly resolved     description: 'Simple X509 certificate parser.',
127 silly resolved     author: { name: 'Colton Baker' },
127 silly resolved     main: './build/Release/x509',
127 silly resolved     repository: { type: 'git', url: 'http://github.com/Southern/node-x509' },
127 silly resolved     scripts: { test: 'node test/test', install: 'node-gyp rebuild' },
127 silly resolved     license: 'MIT',
127 silly resolved     gypfile: true,
127 silly resolved     readme: 'node-x509\n=========\n\n[![Build Status](https://secure.travis-ci.org/Southern/node-x509.png?branch=master)](http://travis-ci.org/Southern/node-x509)\n[![NPM version](https://badge.fury.io/js/x509.png)](http://badge.fury.io/js/x509)\n\nSimple X509 certificate parser.\n\n## Installation\n\nFrom NPM *(recommended)*: `npm install x509`\n\nBuilding and testing from source:\n```\nsudo npm install -g node-gyp\nnpm install\nnpm test\n```\n\n## Usage\nReading from a file:\n```js\nvar x509 = require(\'x509\');\n\nvar issuer = x509.getIssuer(__dirname + \'/certs/your.crt\');\n```\n\nReading from a string:\n```js\nvar fs = require(\'fs\'),\n    x509 = require(\'x509\');\n\nvar issuer = x509.getIssuer(fs.readFileSync(\'./certs/your.crt\').toString());\n```\n\n## Methods\n**Notes:**\n- `cert` may be a filename or a raw base64 encoded PEM string in any of these methods.\n\n\n#### x509.getAltNames(`cert`)\nParse certificate with `x509.parseCert` and return the alternate names.\n\n```js\nvar x509 = require(\'x509\');\n\nvar altNames = x509.getAltNames(__dirname + \'/certs/nodejitsu.com.crt\');\n/*\naltNames = [ \'*.nodejitsu.com\', \'nodejitsu.com\' ]\n*/\n```\n\n#### x509.getIssuer(`cert`)\nParse certificate with `x509.parseCert` and return the issuer.\n\n```js\nvar x509 = require(\'x509\');\n\nvar issuer = x509.getIssuer(__dirname + \'/certs/nodejitsu.com.crt\');\n/*\nissuer = { countryName: \'GB\',\n  stateOrProvinceName: \'Greater Manchester\',\n  localityName: \'Salford\',\n  organizationName: \'COMODO CA Limited\',\n  commonName: \'COMODO High-Assurance Secure Server CA\' }\n*/\n```\n\n#### x509.getSubject(`cert`)\nParse certificate with `x509.parseCert` and return the subject.\n\n```js\nvar x509 = require(\'x509\');\n\nvar subject = x509.getSubject(__dirname + \'/certs/nodejitsu.com.crt\');\n/*\nsubject = { countryName: \'US\',\n  postalCode: \'10010\',\n  stateOrProvinceName: \'NY\',\n  localityName: \'New York\',\n  streetAddress: \'902 Broadway, 4th Floor\',\n  organizationName: \'Nodejitsu\',\n  organizationalUnitName: \'PremiumSSL Wildcard\',\n  commonName: \'*.nodejitsu.com\' }\n*/\n```\n\n#### x509.parseCert(`cert`)\nParse subject, issuer, valid before and after date, and alternate names from certificate.\n\n```js\nvar x509 = require(\'x509\');\n\nvar cert = x509.parseCert(__dirname + \'/certs/nodejitsu.com.crt\');\n/*\ncert = { subject: \n   { countryName: \'US\',\n     postalCode: \'10010\',\n     stateOrProvinceName: \'NY\',\n     localityName: \'New York\',\n     streetAddress: \'902 Broadway, 4th Floor\',\n     organizationName: \'Nodejitsu\',\n     organizationalUnitName: \'PremiumSSL Wildcard\',\n     commonName: \'*.nodejitsu.com\' },\n  issuer: \n   { countryName: \'GB\',\n     stateOrProvinceName: \'Greater Manchester\',\n     localityName: \'Salford\',\n     organizationName: \'COMODO CA Limited\',\n     commonName: \'COMODO High-Assurance Secure Server CA\' },\n  notBefore: Sun Oct 28 2012 20:00:00 GMT-0400 (EDT),\n  notAfter: Wed Nov 26 2014 18:59:59 GMT-0500 (EST),\n  altNames: [ \'*.nodejitsu.com\', \'nodejitsu.com\' ] }\n*/\n```\n\n## Examples\nChecking the date to make sure the certificate is active:\n```js\nvar x509 = require(\'x509\'),\n    cert = x509.parseCert(\'yourcert.crt\'),\n    date = new Date();\n\nif (cert.notBefore > date) {\n  // Certificate isn\'t active yet.\n}\nif (cert.notAfter < date) {\n  // Certificate has expired.\n}\n```\n\n## License\nCopyright (c) 2013 Colton Baker\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n',
127 silly resolved     readmeFilename: 'README.md',
127 silly resolved     bugs: { url: 'https://github.com/Southern/node-x509/issues' },
127 silly resolved     homepage: 'https://github.com/Southern/node-x509',
127 silly resolved     _id: '[email protected]',
127 silly resolved     dist: { shasum: '94881b553707582d9ba2b9dd919b0102d2c1bfde' },
127 silly resolved     _from: 'x509@',
127 silly resolved     _resolved: 'https://registry.npmjs.org/x509/-/x509-0.0.7.tgz' } ]
128 info install [email protected] into /home/mysite/node
129 info installOne [email protected]
130 info /home/mysite/node/node_modules/x509 unbuild
131 verbose tar unpack /root/.npm/x509/0.0.7/package.tgz
132 silly lockFile c914740c--includes-node-node-modules-x509 tar:///home/mysite/node/node_modules/x509
133 verbose lock tar:///home/mysite/node/node_modules/x509 /root/.npm/c914740c--includes-node-node-modules-x509.lock
134 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
135 verbose lock tar:///root/.npm/x509/0.0.7/package.tgz /root/.npm/9ba0da1a--root-npm-x509-0-0-7-package-tgz.lock
136 silly gunzTarPerm modes [ '755', '644' ]
137 silly gunzTarPerm extractEntry package.json
138 silly gunzTarPerm extractEntry .npmignore
139 silly gunzTarPerm extractEntry README.md
140 silly gunzTarPerm extractEntry .travis.yml
141 silly gunzTarPerm extractEntry binding.gyp
142 silly gunzTarPerm extractEntry build/Makefile
143 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/addon.o.d
144 silly gunzTarPerm extractEntry build/Release/.deps/Release/obj.target/x509/src/x509.o.d
145 silly gunzTarPerm extractEntry build/Release/.deps/Release/x509.node.d
146 silly gunzTarPerm extractEntry build/Release/linker.lock
147 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/addon.o
148 silly gunzTarPerm extractEntry build/Release/obj.target/x509/src/x509.o
149 silly gunzTarPerm extractEntry build/Release/x509.node
150 silly gunzTarPerm extractEntry build/binding.Makefile
151 silly gunzTarPerm extractEntry build/config.gypi
152 silly gunzTarPerm extractEntry build/gyp-mac-tool
153 silly gunzTarPerm extractEntry build/x509.target.mk
154 silly gunzTarPerm extractEntry include/addon.h
155 silly gunzTarPerm extractEntry include/x509.h
156 silly gunzTarPerm extractEntry src/addon.cc
157 silly gunzTarPerm extractEntry src/x509.cc
158 silly lockFile c914740c--includes-node-node-modules-x509 tar:///home/mysite/node/node_modules/x509
159 silly lockFile c914740c--includes-node-node-modules-x509 tar:///home/mysite/node/node_modules/x509
160 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
161 silly lockFile 9ba0da1a--root-npm-x509-0-0-7-package-tgz tar:///root/.npm/x509/0.0.7/package.tgz
162 info preinstall [email protected]
163 verbose readDependencies using package.json deps
164 verbose readDependencies using package.json deps
165 silly resolved []
166 verbose about to build /home/mysite/node/node_modules/x509
167 info build /home/mysite/node/node_modules/x509
168 verbose linkStuff [ false,
168 verbose linkStuff   false,
168 verbose linkStuff   false,
168 verbose linkStuff   '/home/mysite/node/node_modules' ]
169 info linkStuff [email protected]
170 verbose linkBins [email protected]
171 verbose linkMans [email protected]
172 verbose rebuildBundles [email protected]
173 info install [email protected]
174 verbose unsafe-perm in lifecycle false
175 info [email protected] Failed to exec install script
176 info /home/mysite/node/node_modules/x509 unbuild
177 info preuninstall [email protected]
178 info uninstall [email protected]
179 verbose true,/home/mysite/node/node_modules,/home/mysite/node/node_modules unbuild [email protected]
180 info postuninstall [email protected]
181 error [email protected] install: `node-gyp rebuild`
181 error Exit status 1
182 error Failed at the [email protected] install script.
182 error This is most likely a problem with the x509 package,
182 error not with npm itself.
182 error Tell the author that this fails on your system:
182 error     node-gyp rebuild
182 error You can get their info via:
182 error     npm owner ls x509
182 error There is likely additional logging output above.
183 error System Linux 2.6.32-431.3.1.el6.x86_64
184 error command "/usr/bin/node" "/usr/bin/npm" "install" "x509"
185 error cwd /home/mysite/node
186 error node -v v0.10.26
187 error npm -v 1.4.3
188 error code ELIFECYCLE
189 verbose exit [ 1, true ]

Any ideas as to what I am doing wrong???

Functions not working with strings.

If I try to use a pure string instead of a path, I get a "Error: File doesn't exist.".
According to documentation:

cert may be a filename or a raw base64 encoded PEM string in any of these methods.

So, what am I doing wrong? It works with paths/filenames, but not PEM encoded strings.

Question/Request: Support of multiple blocks

It is also possible that a cert file might include the CA bundle blocks, which is not supported by this module.
The .ca file itself is then not required. Do you plan to also go that path? Would be a great thing :)

Electron compatibility? Error: %1 is not a valid Win32 application.

I can't seem to get the module to run.

node.exe is 64 bit, OpenSSL win64 was installed (from slpro) and x509 builds against the lib there no problem. However when it come to running, I get this error:

Error: %1 is not a valid Win32 application.
\\?\C:\Users\George\Documents\Code\node_modules\x509\build\Release\x509.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\George\Documents\Code\node_modules\x509\index.js:1:167)
    at Object.<anonymous> (C:\Users\George\Documents\Code\node_modules\x509\index.js:54:3)

Windows support - openssl/asn1.h not found

While not directly related to this project, "npm install x509" fails to build on Windows using msbuild, even if OpenSSL is installed and included in the build paths. Not yet sure if a simple configuration option might resolve this or not.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  addon.cc
  x509.cc
{path}\node_modules\x509\include\x509.h(9): fatal error C1083: Cannot open include file: 'openssl/asn1.h': No such file or directory (..\src\addon.cc) [{path}\node_modules\x509\build\x509.vcxproj]
{path}\node_modules\x509\include\x509.h(9): fatal error C1083: Cannot open include file: 'openssl/asn1.h': No such file or directory (..\src\x509.cc) [{path}\node_modules\x509\build\x509.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit ({user}\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "{user}\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd {path}\node_modules\x509
gyp ERR! node -v v0.10.16
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

Typescript Typings?

Would you be interested in bundling typescript definitions within your package?
The interface of your module is quite simple, I can provide a PR if you are interested.

Otherwise people at the typings repository are willing to help, there is an issue about this : typings/typings#322

serial as integer instead of hex value

Hi, some signatures need to pass the serialNumber as integer, and I can't convert hex to integer because of the limitation of javascript integer, that causes a value of like 45433534+34, would be great if we have a function like this:

x509.parseSerial(cert, { asDecimal: true });

is possible?

Verifying certs as strings

Verify method accepts file paths but I have nothing to do if I have certificates already loaded in RAM. Thus I have to store certificates firstly.

Interpreting a certificate as a string poses security risk

The methods in this library are currently implemented as follows:

  1. Try to interpret the string argument as certificate data.
  2. If this fails, then interpret it as a path.

There are no explicit methods that only accept raw data or a file.

As such, one needs to always apply a safety check before passing certificate data from a third party, since x509 might interpret it as a path and read a sensitive certificate file. A maliciously crafted "certificate" (that is actually a path) could therefore have unintended side effects.

The solution is to have a flag that prohibits interpretation as a path, or to change the method signatures altogether.

Create a fork? Add an additional maintainer?

Hey All,

There's currently 9 open issues, some dating back over a year. Many have PRs waiting to be merged.

I want to try to make an effort here to get the project rolling again, either by adding a new maintainer or by re-engaging the original author.

I'd really like to avoid creating a full on fork but there aren't many other libraries that do this through the openssl C bindings directly.

What version of Opensll does this use?

I may have missed it somewhere but just wanted to verify which version this uses. Also does openssl need to be installed(runnable from command line)?

Not compatible with 0.11.3+

0.11.3 has an update to V8 that deprecates the old style of calling functions and returning their values.

Instead of stuff like:

return scope.Close(exports);

It will end up being something like:

args.GetReturnValue().Set(exports);

parseCert function returns different result for v0.3.3 and v0.3.4

For some certs (in PEM), v0.3.4 version of this package adds extra characters \u0004๏ฟฝ\b+ to the result of x509.parseCert function. The same cert and same code works in v0.3.3.

This is an issue because this makes v0.3.4 version unusable for some PEMs.

x509 fails to compile with Xcode 10.1

> [email protected] install /Users/admejiar/Code/lockhart/lar/node_modules/x509
> node-gyp rebuild

  CXX(target) Release/obj.target/x509/src/addon.o
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead
      [-Wstdlibcxx-not-found]
../src/addon.cc:1:10: fatal error: 'cstdlib' file not found
#include <cstdlib>
         ^~~~~~~~~
1 warning and 1 error generated.
make: *** [Release/obj.target/x509/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/admejiar/.asdf/installs/nodejs/6.11.1/.npm/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/admejiar/.asdf/installs/nodejs/6.11.1/bin/node" "/Users/admejiar/.asdf/installs/nodejs/6.11.1/.npm/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/admejiar/Code/lockhart/lar/node_modules/x509
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/admejiar/.npm/_logs/2018-11-01T01_47_20_961Z-debug.log

SegFault on certain certificates

When parsing certain certificates, for some reason a segmentation fault occurs that comes from the x509 module. When parsing the certificate directly from the CLI with openSSL no error occurs.

An example of the certificate is the one added as cert.txt: (rename to cert.pem)
cert.txt

When executing on:

  • centOS 7.2.1511 64bit
  • Node version 6.3.1
  • X509 version 0.2.6

the following stack trace occurs:

PID 10938 received SIGSEGV for address: 0x0 /root/test/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x1a7b)[0x7f6556050a7b] /lib64/libpthread.so.0(+0xf100)[0x7f655882f100] /lib64/libc.so.6(+0x13aa4f)[0x7f6558598a4f] node(BUF_strlcpy+0x50)[0x8181c0] /root/test/node_modules/x509/build/Release/x509.node(_Z9try_parseRKSs+0x965)[0x7f6556257115] /root/test/node_modules/x509/build/Release/x509.node(_Z10parse_certRKN3Nan20FunctionCallbackInfoIN2v85ValueEEE+0x58)[0x7f6556257b88] /root/test/node_modules/x509/build/Release/x509.node(+0x2b96)[0x7f6556255b96] node(_ZN2v88internal25FunctionCallbackArguments4CallEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEE+0xfe)[0x9484ae] node[0x993bfd] node[0x99414a] [0x288f8890961b]

The simple node.js application used to execute the X509 is the following (I've added the node-segfault-handler module to make sure I get the above stack trace):

test.txt (rename to test.js).

If I execute openssl x509 -in cert.pem from the CLI I get the expected parsed result of the certificate.

The error occurs with only a few certificates, almost all other certificates are parsed with ease, so any idea on what could be wrong or how to fix this would be much appreciated.

Support Node v5.4.0

Node v5.4.0 fails to create hashes after parsing a certificate.

package.json:

{
  "main": "server.js",
  "dependencies": {
    "x509": "^0.2.3"
  }
}

server.js:

var x509 = require("x509");
var crypto = require("crypto");
// x509.parseCert("certificate.cer");
var hash = crypto.createHash("md5");
console.log(hash.digest("hex"));

Uncomment the line and the following error will be thrown:

crypto.js:50
  this._handle = new binding.Hash(algorithm);
                 ^

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Error (native)
    at new Hash (crypto.js:50:18)
    at Object.Hash (crypto.js:49:12)
    at Object.<anonymous> (/home/christian/Documents/sandbox/server.js:4:19)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:430:10)
    at startup (node.js:141:18)

Does not compile with node 0.11.9

> npm install --save x509
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm http GET https://registry.npmjs.org/x509
npm http 304 https://registry.npmjs.org/x509

> [email protected] install /home/rush/Programowanie/x509-test/node_modules/x509
> node-gyp rebuild

make: Entering directory `/home/rush/Programowanie/x509-test/node_modules/x509/build'
  CXX(target) Release/obj.target/x509/src/addon.o
In file included from /home/rush/.node-gyp/0.11.9/src/node.h:61:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h: In member function 'void v8::ReturnValue<T>::Set(uint32_t)':
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h:5816:31: warning: typedef 'I' locally defined but not used [-Wunused-local-typedefs]
   typedef internal::Internals I;
                               ^
In file included from ../src/addon.cc:5:0:
../include/x509.h: At global scope:
../include/x509.h:25:36: error: 'Arguments' does not name a type
   Handle<Value> get_altnames(const Arguments &args);
                                    ^
../include/x509.h:25:47: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
   Handle<Value> get_altnames(const Arguments &args);
                                               ^
../include/x509.h:26:35: error: 'Arguments' does not name a type
   Handle<Value> get_subject(const Arguments &args);
                                   ^
../include/x509.h:26:46: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
   Handle<Value> get_subject(const Arguments &args);
                                              ^
../include/x509.h:27:34: error: 'Arguments' does not name a type
   Handle<Value> get_issuer(const Arguments &args);
                                  ^
../include/x509.h:27:45: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
   Handle<Value> get_issuer(const Arguments &args);
                                             ^
../include/x509.h:28:34: error: 'Arguments' does not name a type
   Handle<Value> parse_cert(const Arguments &args);
                                  ^
../include/x509.h:28:45: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
   Handle<Value> parse_cert(const Arguments &args);
                                             ^
../src/addon.cc: In function 'void init(v8::Handle<v8::Object>)':
../src/addon.cc:11:84: error: invalid conversion from 'v8::Handle<v8::Value> (*)(const int&)' to 'v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}' [-fpermissive]
   exports->Set(String::NewSymbol("getAltNames"), FunctionTemplate::New(get_altnames)->GetFunction());
                                                                                    ^
In file included from /home/rush/.node-gyp/0.11.9/src/node.h:61:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h:3346:34: error:   initializing argument 1 of 'static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)' [-fpermissive]
   static Local<FunctionTemplate> New(
                                  ^
../src/addon.cc:12:82: error: invalid conversion from 'v8::Handle<v8::Value> (*)(const int&)' to 'v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}' [-fpermissive]
   exports->Set(String::NewSymbol("getSubject"), FunctionTemplate::New(get_subject)->GetFunction());
                                                                                  ^
In file included from /home/rush/.node-gyp/0.11.9/src/node.h:61:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h:3346:34: error:   initializing argument 1 of 'static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)' [-fpermissive]
   static Local<FunctionTemplate> New(
                                  ^
../src/addon.cc:13:80: error: invalid conversion from 'v8::Handle<v8::Value> (*)(const int&)' to 'v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}' [-fpermissive]
   exports->Set(String::NewSymbol("getIssuer"), FunctionTemplate::New(get_issuer)->GetFunction());
                                                                                ^
In file included from /home/rush/.node-gyp/0.11.9/src/node.h:61:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h:3346:34: error:   initializing argument 1 of 'static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)' [-fpermissive]
   static Local<FunctionTemplate> New(
                                  ^
../src/addon.cc:14:80: error: invalid conversion from 'v8::Handle<v8::Value> (*)(const int&)' to 'v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}' [-fpermissive]
   exports->Set(String::NewSymbol("parseCert"), FunctionTemplate::New(parse_cert)->GetFunction());
                                                                                ^
In file included from /home/rush/.node-gyp/0.11.9/src/node.h:61:0,
                 from ../include/addon.h:4,
                 from ../src/addon.cc:4:
/home/rush/.node-gyp/0.11.9/deps/v8/include/v8.h:3346:34: error:   initializing argument 1 of 'static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)' [-fpermissive]
   static Local<FunctionTemplate> New(
                                  ^
make: *** [Release/obj.target/x509/src/addon.o] Error 1
make: Leaving directory `/home/rush/Programowanie/x509-test/node_modules/x509/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/rush/.nvm/v0.11.9/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:101:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:827:12)
gyp ERR! System Linux 3.11.6-4-desktop
gyp ERR! command "node" "/home/rush/.nvm/v0.11.9/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/rush/Programowanie/x509-test/node_modules/x509
gyp ERR! node -v v0.11.9
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the x509 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls x509
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.6-4-desktop
npm ERR! command "/home/rush/.nvm/v0.11.9/bin/node" "/home/rush/.nvm/v0.11.9/bin/npm" "install" "--save" "x509"
npm ERR! cwd /home/rush/Programowanie/x509-test
npm ERR! node -v v0.11.9
npm ERR! npm -v 1.3.15
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/rush/Programowanie/x509-test/npm-debug.log
npm ERR! not ok code 0

Error: Module version mismatch. Expected 48, got 67.

Getting lots of these lately, I'm unable to run code using the x509 module. Using node v11.10.0.

15|ereside | Error: Module version mismatch. Expected 48, got 67.
15|ereside |     at Error (native)
15|ereside |     at Object.Module._extensions..node (module.js:604:18)
15|ereside |     at Module.load (module.js:494:32)
15|ereside |     at tryModuleLoad (module.js:453:12)
15|ereside |     at Function.Module._load (module.js:445:3)
15|ereside |     at Module.require (module.js:504:17)
15|ereside |     at require (internal/module.js:20:19)
15|ereside |     at Object.<anonymous> (/route/to/project/node_modules/x509/index.js:1:74)

Any help greatly appreciated.
Already tried npm rebuild, removing node_modules and installing everything again, etc...
Npm version: 6.8.0
Server is Linux Debian 8.11.

virtkick-proxy not available

I get git fetch -a origin (git://github.com/virtkick/virtkick-proxy.git) fatal: remote error: when installing virtkick-starter

Remove read from file fallback

I'm using the parser with user submitted input

const cert = x509.parseCert(userInput)

currently a user could read an arbitrary file from file system using the x509 parser and I've no chance to tell the parser not to do so. This is why I'd suggest removing the fallback read-from-fs. If this functionality is needed, one can still use the parser as as described in the readme:

const fs = require('fs'),
      x509 = require('x509');
var issuer = x509.getIssuer(fs.readFileSync('./certs/your.crt').toString());

Reading PEM key for the purpose of finding a matching certificate

I would like to ask here for RFC.
https://github.com/CodeCharmLtd/node-x509/tree/parse-pem
I have added a method: persePem which would return an object with fields publicModulus and publicExponent. Same fields have been added to parseCert.
If both cert and pem have the same values - they are a matching pair. I think this belong to node-x509 quite well but I would like to get a second opinion and before I do a second pull request the first one needs to get finished.

It fail to install after upgrading to El Capitan

This is the output:

> [email protected] preinstall /myproject/something/foo/node_modules/.staging/x509-af6e96e0e7b4c49d655e9d9be3833418
> make

cat version.gypi | sed -e s/{{VERSION}}/0.0.4/ > build/version.gypi
node-gyp configure build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn python2
gyp info spawn args [ '/Users/jose/.nave/installed/0.10.40/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/myproject/something/foo/node_modules/.staging/x509-af6e96e0e7b4c49d655e9d9be3833418/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/jose/.nave/installed/0.10.40/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/jose/.node-gyp/0.10.40/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/jose/.node-gyp/0.10.40',
gyp info spawn args   '-Dnode_gyp_dir=/Users/jose/.nave/installed/0.10.40/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/myproject/something/foo/node_modules/.staging/x509-af6e96e0e7b4c49d655e9d9be3833418',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/x509/src/addon.o
In file included from ../src/addon.cc:2:
../include/x509.h:10:10: fatal error: 'openssl/asn1.h' file not found
#include <openssl/asn1.h>
         ^
1 error generated.
make[1]: *** [Release/obj.target/x509/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/jose/.nave/installed/0.10.40/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "node" "/Users/jose/.nave/installed/0.10.40/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /myproject/something/foo/node_modules/.staging/x509-af6e96e0e7b4c49d655e9d9be3833418
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
make: *** [all] Error 1
npm info lifecycle [email protected]~preinstall: Failed to exec preinstall script

Empty public key?

let cert = x509.parseCert(myCertificatePath);
console.log("Certificate public key:");
console.log(cert.publicKey);

My console only prints:
{ algorithm: 'id-ecPublicKey' }

Am I not supposed to see the actual public key or other unique information about it?

FYI, the test certificate is:

-----BEGIN CERTIFICATE-----
MIICkDCCAjegAwIBAgIUCL+kBzVdqMGzurpuYwIxkuLbYrgwCgYIKoZIzj0EAwIw
czELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh
biBGcmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMT
E2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMTkwMjA1MDgyMjAwWhcNMjAwMjA1MDgy
NzAwWjBDMTAwDQYDVQQLEwZjbGllbnQwCwYDVQQLEwRvcmcxMBIGA1UECxMLZGVw
YXJ0bWVudDExDzANBgNVBAMTBm5hdGhhbjBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABIyUQwDC/2N/wUAoMDGuc8ZZUYEHNsPC3dVCuszmL8M7ALMXVcfu/qJhu+lh
70/RC9/md2phgGSWouRccBHftXOjgdgwgdUwDgYDVR0PAQH/BAQDAgeAMAwGA1Ud
EwEB/wQCMAAwHQYDVR0OBBYEFJYSgUGno6j2eYUKjLs9BRzreUY1MCsGA1UdIwQk
MCKAIEI5qg3NdtruuLoM2nAYUdFFBNMarRst3dusalc2Xkl8MGkGCCoDBAUGBwgB
BF17ImF0dHJzIjp7ImhmLkFmZmlsaWF0aW9uIjoib3JnMS5kZXBhcnRtZW50MSIs
ImhmLkVucm9sbG1lbnRJRCI6Im5hdGhhbiIsImhmLlR5cGUiOiJjbGllbnQifX0w
CgYIKoZIzj0EAwIDRwAwRAIgbYQ4UscWT5rgqLwrhcj8kRNN0kfA5n12Zpl1Fclw
+7QCIAlTx9oMsGBAeaNxJ3PV6mo9Zng5aMNnAmwW2PVcDlXt
-----END CERTIFICATE-----

Possible Issue with Modulus being reported?

When I compare the Modulus being reported by openssl vs. the what's coming in x509 publicKey, I'm seeing two different values. I fully admit this may be due to a gap in my understanding, and if so apologies.

I've made a test case and attached here, consisting of a shell script (to call openssl), a node app (to use x509) and a cert.

code.zip

Does not work for DER encoded certificates

It would be nice if this worked on DER (PKCS7) encoded certificates, and if that get's added in, might as well throw in PKCS12 as well. I wouldn't mind implementing if someone could show me a good way to differentiate in code. I don't see a friendly way to do this in the openssl library. Or should the node x509 library just try all three if passed a cert and return on the one that does not exception out (not a fan of using exceptions as a program flow)?

verify result is undefined

Hello,

Given this snippet of code:

let myCertificatePath = path.join(__dirname, 'nathan.crt');
let caBundlePath = path.join(__dirname, 'ca-bundle.pem');
x509.verify(myCertificatePath, caBundlePath, function(err, result){
    console.log("finished validation");
    if(err){
        console.log("validation error");
        console.log(err);
    } else {
        console.log("validation result");
        console.log(result);
    }
});

My console log prints:

validation result
undefined

What does it mean? What could lead result to be undefined, without any errors?

Issue building with node 10.0.0?

After upgrading to node 10.0.0, I had some issues installing x509. node-gyp 'make' was failing with some errors that seemed indicative of some kind of breaking interface change. However this is not the analysis of an expert in such things :) Downgrading node to 9.5.0 (or 9.11.1) fixes the issue without any further action needed. If this is actually an issue with node, or node-gyp, or my own environment, please accept my apologies and close this issue!
10.0.0_build.log

Support for files with multiple PEM CAs?

I don't believe that there is any support for a PEM file that contains multiple CAs. Is that right? If so, there any plans to support this?

If the file contained multiple PEMs, the caller could parse the file, but even then, you can't call parseCert() with a string representation of the PEM CA, right? It has to be a file reference?

Error: version `GLIBCXX_3.4.21' not found

Hello. I'm attempting to use this package on a Ubuntu 14.04 machine and receiving the following error:

module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/share/openhim-cert-updater/node_modules/x509/build/Release/x509.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/share/openhim-cert-updater/node_modules/x509/index.js:1:74)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

Is there any way to eliminate this dependency or does anyone know a work around for this?

I understand if not. Thank you for your time.

Node 8+ deprecation issues

Hey there,
When deploying server code to google app engine running node LTS, I get the following few errors:

In file included from ../node_modules/nan/nan.h:194:0,
from ../include/x509.h:7,
from ../src/addon.cc:5:
 ../node_modules/nan/nan_maybe_43_inl.h: In function 'Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array>, uint32_t)':
 ../node_modules/nan/nan_maybe_43_inl.h:220:58: warning: 'v8::MaybeLocal<v8::Object> v8::Array::CloneElementAt(v8::Local<v8::Context>, uint32_t)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:3516): Cloning is not supported. [-Wdeprecated-declarations]
    return array->CloneElementAt(GetCurrentContext(), index);
                                                           ^
In file included from ../node_modules/nan/nan_new.h:189:0,
                  from ../node_modules/nan/nan.h:200,
                  from ../include/x509.h:7,
                  from ../src/addon.cc:5:
../node_modules/nan/nan_implementation_12_inl.h: In static member function 'static Nan::imp::FactoryBase<v8::BooleanObject>::return_t Nan::imp::Factory<v8::BooleanObject>::New(bool)':
../node_modules/nan/nan_implementation_12_inl.h:40:38: warning: 'static v8::Local<v8::Value> v8::BooleanObject::New(bool)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:4845): Pass an isolate [-Wdeprecated-declarations]
    return v8::BooleanObject::New(value).As<v8::BooleanObject>();
                                       ^
 In file included from ../include/x509.h:7:0,
                  from ../src/addon.cc:5:
 ../node_modules/nan/nan.h: In function 'bool Nan::SetAccessor(v8::Local<v8::Object>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)':
 ../node_modules/nan/nan.h:1969:16: warning: 'bool v8::Object::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:3186): Use maybe version [-Wdeprecated-declarations]
      , attribute);
                 ^
   CXX(target) Release/obj.target/x509/src/x509.o
 In file included from ../node_modules/nan/nan.h:194:0,
                  from ../include/x509.h:7,
                  from ../src/x509.cc:3:
 ../node_modules/nan/nan_maybe_43_inl.h: In function 'Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array>, uint32_t)':
 ../node_modules/nan/nan_maybe_43_inl.h:220:58: warning: 'v8::MaybeLocal<v8::Object> v8::Array::CloneElementAt(v8::Local<v8::Context>, uint32_t)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:3516): Cloning is not supported. [-Wdeprecated-declarations]
    return array->CloneElementAt(GetCurrentContext(), index);
                                                           ^
 In file included from ../node_modules/nan/nan_new.h:189:0,
                  from ../node_modules/nan/nan.h:200,
                  from ../include/x509.h:7,
                  from ../src/x509.cc:3:
 ../node_modules/nan/nan_implementation_12_inl.h: In static member function 'static Nan::imp::FactoryBase<v8::BooleanObject>::return_t Nan::imp::Factory<v8::BooleanObject>::New(bool)':
 ../node_modules/nan/nan_implementation_12_inl.h:40:38: warning: 'static v8::Local<v8::Value> v8::BooleanObject::New(bool)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:4845): Pass an isolate [-Wdeprecated-declarations]
    return v8::BooleanObject::New(value).As<v8::BooleanObject>();
                                       ^
 In file included from ../include/x509.h:7:0,
                  from ../src/x509.cc:3:
 ../node_modules/nan/nan.h: In function 'bool Nan::SetAccessor(v8::Local<v8::Object>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)':
 ../node_modules/nan/nan.h:1969:16: warning: 'bool v8::Object::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:3186): Use maybe version [-Wdeprecated-declarations]
      , attribute);
                 ^
 ../src/x509.cc: In function 'v8::Local<v8::Value> try_parse(const string&)':
 ../src/x509.cc:368:38: warning: value computed is not used [-Wunused-value]
      BIO_set_close(ext_bio, BIO_CLOSE);
                                       ^
 ../src/x509.cc: In function 'v8::Local<v8::Value> parse_date(ASN1_TIME*)':
 ../src/x509.cc:433:60: warning: 'v8::Local<v8::Value> v8::Object::CallAsConstructor(int, v8::Local<v8::Value>*)' is deprecated (declared at /root/.node-gyp/8.11.1/include/node/v8.h:3481): Use maybe version [-Wdeprecated-declarations]
    return scope.Escape(DateObject->CallAsConstructor(1, args));

Javascript version - no more build issues

I have been happily using node-x509 for a long time. Thanks for this project!
Unfortunately I encountered numerous installation issues due to native code and reliance on openssl headers.

For those concerned with the above, I have created a javascript (libcrypto compiled with emscripten) version of the same functionality:
https://github.com/CodeCharmLtd/x509.js

Sorry for shameful advertisement, I think it may be useful to some users.

warnings occuring during npm install in node version 8

following warnings messages occur during npm install x509 for node version 8.1.2

  CXX(target) Release/obj.target/x509/src/addon.o
In file included from ../src/addon.cc:5:
In file included from ../include/x509.h:7:
In file included from ../node_modules/nan/nan.h:194:
../node_modules/nan/nan_maybe_43_inl.h:220:17: warning: 'CloneElementAt' is deprecated [-Wdeprecated-declarations]
  return array->CloneElementAt(GetCurrentContext(), index);
                ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:3341:36: note: 'CloneElementAt' has been explicitly marked deprecated here
                MaybeLocal<Object> CloneElementAt(Local<Context> context,
                                   ^
In file included from ../src/addon.cc:5:
In file included from ../include/x509.h:7:
In file included from ../node_modules/nan/nan.h:200:
In file included from ../node_modules/nan/nan_new.h:189:
../node_modules/nan/nan_implementation_12_inl.h:40:29: warning: 'New' is deprecated [-Wdeprecated-declarations]
  return v8::BooleanObject::New(value).As<v8::BooleanObject>();
                            ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:4532:56: note: 'New' has been explicitly marked deprecated here
  V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
                                                       ^
In file included from ../src/addon.cc:5:
In file included from ../include/x509.h:7:
../node_modules/nan/nan.h:1963:15: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
  return obj->SetAccessor(
              ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:3021:22: note: 'SetAccessor' has been explicitly marked deprecated here
                bool SetAccessor(Local<Name> name,
                     ^
3 warnings generated.
  CXX(target) Release/obj.target/x509/src/x509.o
In file included from ../src/x509.cc:3:
In file included from ../include/x509.h:7:
In file included from ../node_modules/nan/nan.h:194:
../node_modules/nan/nan_maybe_43_inl.h:220:17: warning: 'CloneElementAt' is deprecated [-Wdeprecated-declarations]
  return array->CloneElementAt(GetCurrentContext(), index);
                ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:3341:36: note: 'CloneElementAt' has been explicitly marked deprecated here
                MaybeLocal<Object> CloneElementAt(Local<Context> context,
                                   ^
In file included from ../src/x509.cc:3:
In file included from ../include/x509.h:7:
In file included from ../node_modules/nan/nan.h:200:
In file included from ../node_modules/nan/nan_new.h:189:
../node_modules/nan/nan_implementation_12_inl.h:40:29: warning: 'New' is deprecated [-Wdeprecated-declarations]
  return v8::BooleanObject::New(value).As<v8::BooleanObject>();
                            ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:4532:56: note: 'New' has been explicitly marked deprecated here
  V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
                                                       ^
In file included from ../src/x509.cc:3:
In file included from ../include/x509.h:7:
../node_modules/nan/nan.h:1963:15: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
  return obj->SetAccessor(
              ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:3021:22: note: 'SetAccessor' has been explicitly marked deprecated here
                bool SetAccessor(Local<Name> name,
                     ^
../src/x509.cc:448:35: warning: 'CallAsConstructor' is deprecated [-Wdeprecated-declarations]
  return scope.Escape(DateObject->CallAsConstructor(1, args));
                                  ^
/Users/deepak/.node-gyp/8.1.2/include/node/v8.h:3306:30: note: 'CallAsConstructor' has been explicitly marked deprecated here
                Local<Value> CallAsConstructor(int argc, Local<Value> argv[]));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.