Skip to content

Commit

Permalink
fix(package): fix check pkcs12 openssl1.1.0 not printed "MAC verified…
Browse files Browse the repository at this point in the history
… OK" (#140)

* fix(package): parse serial and fix getDhparamInfo (#136)

* chore(package): update semantic-release to version 8.0.0

* Add OpenSSL Matrix

* make test use of self builded "/openssl/bin/openssl"

* fix getDhparamInfo

* Fix Tests for Travis and Empty OPENSSL_DIR

* * chore(package): Reviewautomatedtests (#138)

* chore(package): update semantic-release to version 8.0.0

* review tests; standardjs; changelog; grunt removal

* fix(travis): build travis with `npm run test`

* fix(tests): password must be 4 to 1023 characters

* chore(build): move back after build

* fix(package): parse serial and fix getDhparamInfo (#136)

* chore(package): update semantic-release to version 8.0.0

* Add OpenSSL Matrix

* make test use of self builded "/openssl/bin/openssl"

* fix getDhparamInfo

* Fix Tests for Travis and Empty OPENSSL_DIR

* * chore(package): Reviewautomatedtests (#138)

* chore(package): update semantic-release to version 8.0.0

* review tests; standardjs; changelog; grunt removal

* fix(travis): build travis with `npm run test`

* fix(tests): password must be 4 to 1023 characters

* chore(build): move back after build

* fix(package): fix check pkcs12 openssl1.1.0 not
printed "MAC verified OK"

* fix PR fails
  • Loading branch information
Dexus committed Sep 20, 2017
1 parent 14c503f commit 7e97261
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
5 changes: 3 additions & 2 deletions lib/pem.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ function checkPkcs12 (bufferOrPath, passphrase, callback) {
}

var tmpfiles = []
var args = ['pkcs12', '-info', '-in', bufferOrPath, '-noout', '-nodes', '-passin', 'pass:' + passphrase]
var args = ['pkcs12', '-info', '-in', bufferOrPath, '-noout', '-maciter', '-nodes', '-passin', 'pass:' + passphrase]

if (Buffer.isBuffer(bufferOrPath)) {
tmpfiles = [bufferOrPath]
Expand All @@ -778,7 +778,8 @@ function checkPkcs12 (bufferOrPath, passphrase, callback) {
if (err) {
return callback(err)
}
callback(null, /MAC verified OK/im.test(stderr))
console.log(err, code, stdout, stderr)
callback(null, (/MAC verified OK/im.test(stderr) || (!(/MAC verified OK/im.test(stderr)) && !(/Mac verify error/im.test(stderr)))))
})
}

Expand Down
36 changes: 12 additions & 24 deletions test/pem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,26 +435,16 @@ describe('General Tests', function () {
pem.readPkcs12(d.pkcs12,
function (error, keystore) {
hlp.checkError(error)
expect(keystore).to.be.an(
'object')
expect(keystore).to.have
.property('ca')
expect(keystore).to.have
.property('cert')
expect(keystore).to.have
.property('key')
expect(keystore.ca).to.be
.an('array')
expect(keystore.cert).to
.be.an('string')
expect(keystore.key).to
.be.an('string')
expect(keystore.ca[0]).to
.equal(ca.certificate)
expect(keystore.cert).to
.equal(data.certificate)
expect(keystore.key).to
.equal(data.clientKey)
expect(keystore).to.be.an('object')
expect(keystore).to.have.property('ca')
expect(keystore).to.have.property('cert')
expect(keystore).to.have.property('key')
expect(keystore.ca).to.be.an('array')
expect(keystore.cert).to.be.an('string')
expect(keystore.key).to.be.an('string')
expect(keystore.ca[0]).to.equal(ca.certificate)
expect(keystore.cert).to.equal(data.certificate)
expect(keystore.key).to.equal(data.clientKey)
done()
})
})
Expand Down Expand Up @@ -684,10 +674,8 @@ describe('General Tests', function () {

describe('#.checkPkcs12 tests', function () {
it('Check PKCS12 keystore', function (done) {
var pkcs12 = fs.readFileSync(
'./test/fixtures/idsrv3test.pfx')
pem.checkPkcs12(pkcs12, 'idsrv3test', function (error,
result) {
var pkcs12 = fs.readFileSync('./test/fixtures/idsrv3test.pfx')
pem.checkPkcs12(pkcs12, 'idsrv3test', function (error, result) {
hlp.checkError(error)
expect(result).to.be.ok()
done()
Expand Down
18 changes: 16 additions & 2 deletions test_build_openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,27 @@ tar --strip-components=1 -xzf ${OUT}

case "${LIBRARY}" in
"openssl")
./Configure --prefix=${OPENSSL_DIR} ${OS_COMPILER} -fPIC -g ${OS_FLAGS} no-shared
./Configure --prefix=${OPENSSL_DIR} ${OS_COMPILER} -fPIC -g ${OS_FLAGS} no-shared -static
;;
"libressl")
./configure --prefix=${OPENSSL_DIR} --disable-shared --with-pic
;;
esac

make -j$(nproc)
sudo make install
sudo make install_sw

case "${LIBRARY}" in
"openssl")
if [[ ! -f "${OPENSSL_DIR}/ssl/openssl.cnf" ]]; then sudo mkdir -p ${OPENSSL_DIR}/ssl && sudo cp apps/openssl.cnf ${OPENSSL_DIR}/ssl/openssl.cnf ; fi
;;
"libressl")
if [[ ! -f "${OPENSSL_DIR}/ssl/openssl.cnf" ]]; then sudo mkdir -p ${OPENSSL_DIR}/ssl && sudo cp apps/openssl/openssl.cnf ${OPENSSL_DIR}/ssl/openssl.cnf ; fi
;;
esac

sudo chmod -Rf 0755 /openssl

cd ${NORMALPATH}

rm -r -f node_modules && npm i

0 comments on commit 7e97261

Please sign in to comment.