Use best binding
This commit is contained in:
Родитель
efdb9166e4
Коммит
ebea62da10
|
@ -7,7 +7,8 @@ forge = require 'node-forge'
|
|||
pki = forge.pki
|
||||
asn1 = forge.asn1
|
||||
|
||||
each = require './each'
|
||||
each = require '..'
|
||||
.each
|
||||
module.exports =
|
||||
all = []
|
||||
|
||||
|
|
|
@ -6,23 +6,23 @@ Returns:
|
|||
cb(null, crt): certificate
|
||||
cb(): done
|
||||
###
|
||||
path = require 'path'
|
||||
spawn = require 'child_process'
|
||||
.spawn
|
||||
|
||||
split = require 'split'
|
||||
crypt = require "./binding"
|
||||
forge = require 'node-forge'
|
||||
|
||||
asn1 = forge.asn1
|
||||
pki = forge.pki
|
||||
|
||||
module.exports = (cb)->
|
||||
spawn path.join __dirname, 'roots'
|
||||
.stdout.pipe split (blob)->
|
||||
unless blob
|
||||
module.exports = (cb)-> setImmediate ->
|
||||
store = crypt()
|
||||
do step = -> setImmediate ->
|
||||
try
|
||||
if blob = store.next()
|
||||
cb null, pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
do step
|
||||
else
|
||||
store.done()
|
||||
do cb
|
||||
return
|
||||
blob = Buffer.from blob, 'hex'
|
||||
cb null, pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
.on 'end', ->
|
||||
cb null
|
||||
return
|
||||
catch error
|
||||
store.done()
|
||||
cb error
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
###
|
||||
Asynchronous enumeration
|
||||
|
||||
Returns:
|
||||
cb(error): error
|
||||
cb(null, crt): certificate
|
||||
cb(): done
|
||||
###
|
||||
path = require 'path'
|
||||
spawn = require 'child_process'
|
||||
.spawn
|
||||
|
||||
split = require 'split'
|
||||
forge = require 'node-forge'
|
||||
|
||||
asn1 = forge.asn1
|
||||
pki = forge.pki
|
||||
|
||||
module.exports = (cb)->
|
||||
spawn path.join __dirname, 'roots'
|
||||
.stdout.pipe split (blob)->
|
||||
unless blob
|
||||
return
|
||||
blob = Buffer.from blob, 'hex'
|
||||
cb null, pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
.on 'end', ->
|
||||
cb null
|
||||
return
|
|
@ -0,0 +1 @@
|
|||
module.exports = require "./crypt32-#{process.arch}"
|
|
@ -1,22 +1,16 @@
|
|||
###
|
||||
Enumerate system root CAs synchronously
|
||||
###
|
||||
path = require 'path'
|
||||
spawn = require 'child_process'
|
||||
.spawnSync
|
||||
|
||||
split = require 'split'
|
||||
crypt = require "./binding"
|
||||
forge = require 'node-forge'
|
||||
|
||||
asn1 = forge.asn1
|
||||
pki = forge.pki
|
||||
|
||||
module.exports = (cb)->
|
||||
child = spawn path.join __dirname, 'roots'
|
||||
split (blob)->
|
||||
unless blob
|
||||
return
|
||||
blob = Buffer.from blob, 'hex'
|
||||
cb pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
.end child.stdout
|
||||
return
|
||||
store = crypt()
|
||||
try
|
||||
while blob = store.next()
|
||||
cb pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
finally
|
||||
store.done()
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
###
|
||||
Enumerate system root CAs synchronously
|
||||
###
|
||||
path = require 'path'
|
||||
spawn = require 'child_process'
|
||||
.spawnSync
|
||||
|
||||
split = require 'split'
|
||||
forge = require 'node-forge'
|
||||
|
||||
asn1 = forge.asn1
|
||||
pki = forge.pki
|
||||
|
||||
module.exports = (cb)->
|
||||
child = spawn path.join __dirname, 'roots'
|
||||
split (blob)->
|
||||
unless blob
|
||||
return
|
||||
blob = Buffer.from blob, 'hex'
|
||||
cb pki.certificateFromAsn1 asn1.fromDer blob.toString 'binary'
|
||||
.end child.stdout
|
||||
return
|
|
@ -3,14 +3,17 @@ if process.platform != 'win32'
|
|||
|
||||
require './format.oids'
|
||||
|
||||
if @nApi = !!process.versions.napi
|
||||
each = require './each'
|
||||
each.async = require './async'
|
||||
else
|
||||
each = require './each.fallback'
|
||||
each.async = require './async.fallback'
|
||||
@each = each
|
||||
|
||||
@all = ->
|
||||
require './all'
|
||||
|
||||
require './inject'
|
||||
@path = require './save'
|
||||
.path
|
||||
|
||||
@each = require './each'
|
||||
|
||||
@async = (cb)->
|
||||
require('./async') cb
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
###
|
||||
Test name_hash[_old]
|
||||
###
|
||||
self = require '..'
|
||||
|
||||
console.log "Using N-API:", if self.nApi then "yes" else "no"
|
|
@ -4,7 +4,7 @@ Test asynchronous enumeration
|
|||
assert = require 'assert'
|
||||
|
||||
async = require '..'
|
||||
.async
|
||||
.each.async
|
||||
|
||||
N = 0
|
||||
async (error, crt)->
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
###
|
||||
Fail HTTPS request when no Root CAs available
|
||||
###
|
||||
url = require 'url'
|
||||
https = require 'https'
|
||||
|
||||
options = url.parse 'https://ya.ru'
|
||||
options.agent = new https.Agent ca: []
|
||||
https.get options, ->
|
||||
throw Error 'HTTPS without Root CAs succeeded!'
|
||||
.on 'error', ->
|
||||
console.log 'HTTPS is tested to fail without Root CAs.'
|
||||
###
|
||||
Fail HTTPS request when no Root CAs available
|
||||
###
|
||||
url = require 'url'
|
||||
https = require 'https'
|
||||
|
||||
options = url.parse 'https://ya.ru'
|
||||
options.agent = new https.Agent ca: []
|
||||
https.get options, ->
|
||||
throw Error 'HTTPS without Root CAs succeeded!'
|
||||
.on 'error', ->
|
||||
console.log 'HTTPS is tested to fail without Root CAs.'
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
###
|
||||
Test name_hash[_old]
|
||||
###
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
assert = require 'assert'
|
||||
forge = require 'node-forge'
|
||||
pki = forge.pki
|
||||
asn1 = forge.asn1
|
||||
|
||||
hash = require '../lib/hash'
|
||||
hach = require '../lib/hash_old'
|
||||
|
||||
pem = fs.readFileSync path.join __dirname, 'uxm.pem'
|
||||
crt = pki.certificateFromPem pem
|
||||
|
||||
assert.equal 0x3aa90a40, hach crt.subject
|
||||
assert.equal 0x09926f58, hash crt.subject
|
||||
|
||||
console.log "Hashes ok:", 2
|
||||
###
|
||||
Test name_hash[_old]
|
||||
###
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
assert = require 'assert'
|
||||
forge = require 'node-forge'
|
||||
pki = forge.pki
|
||||
asn1 = forge.asn1
|
||||
|
||||
hash = require '../lib/hash'
|
||||
hach = require '../lib/hash_old'
|
||||
|
||||
pem = fs.readFileSync path.join __dirname, 'uxm.pem'
|
||||
crt = pki.certificateFromPem pem
|
||||
|
||||
assert.equal 0x3aa90a40, hach crt.subject
|
||||
assert.equal 0x09926f58, hash crt.subject
|
||||
|
||||
console.log "Hashes ok:", 2
|
||||
|
|
|
@ -3,11 +3,9 @@ path = require 'path'
|
|||
|
||||
return if do require './mutex'
|
||||
|
||||
N=0
|
||||
|
||||
fs.readdirSync __dirname
|
||||
.forEach (f)-> setImmediate ->
|
||||
return unless '.coffee' == path.extname f
|
||||
try
|
||||
require "./#{f}"
|
||||
catch e
|
||||
console.error e.message
|
||||
console.log e.stack
|
||||
require "./#{f}"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
assert = require 'assert'
|
||||
https = require 'https'
|
||||
|
||||
require '..'
|
||||
|
||||
assert Array.isArray ca = https.globalAgent.options.ca
|
||||
assert ca.length
|
||||
|
||||
https.get uri = 'https://ya.ru', ->
|
||||
console.log "HTTPS GET", uri, "succeeded."
|
||||
assert = require 'assert'
|
||||
https = require 'https'
|
||||
|
||||
require '..'
|
||||
|
||||
assert Array.isArray ca = https.globalAgent.options.ca
|
||||
assert ca.length
|
||||
|
||||
https.get uri = 'https://ya.ru', ->
|
||||
console.log "HTTPS GET", uri, "succeeded."
|
||||
|
|
Загрузка…
Ссылка в новой задаче