Skip to content

Commit 7e97261

Browse files
authored
fix(package): fix check pkcs12 openssl1.1.0 not printed "MAC verified 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
1 parent 14c503f commit 7e97261

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

lib/pem.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ function checkPkcs12 (bufferOrPath, passphrase, callback) {
767767
}
768768

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

772772
if (Buffer.isBuffer(bufferOrPath)) {
773773
tmpfiles = [bufferOrPath]
@@ -778,7 +778,8 @@ function checkPkcs12 (bufferOrPath, passphrase, callback) {
778778
if (err) {
779779
return callback(err)
780780
}
781-
callback(null, /MAC verified OK/im.test(stderr))
781+
console.log(err, code, stdout, stderr)
782+
callback(null, (/MAC verified OK/im.test(stderr) || (!(/MAC verified OK/im.test(stderr)) && !(/Mac verify error/im.test(stderr)))))
782783
})
783784
}
784785

test/pem.spec.js

+12-24
Original file line numberDiff line numberDiff line change
@@ -435,26 +435,16 @@ describe('General Tests', function () {
435435
pem.readPkcs12(d.pkcs12,
436436
function (error, keystore) {
437437
hlp.checkError(error)
438-
expect(keystore).to.be.an(
439-
'object')
440-
expect(keystore).to.have
441-
.property('ca')
442-
expect(keystore).to.have
443-
.property('cert')
444-
expect(keystore).to.have
445-
.property('key')
446-
expect(keystore.ca).to.be
447-
.an('array')
448-
expect(keystore.cert).to
449-
.be.an('string')
450-
expect(keystore.key).to
451-
.be.an('string')
452-
expect(keystore.ca[0]).to
453-
.equal(ca.certificate)
454-
expect(keystore.cert).to
455-
.equal(data.certificate)
456-
expect(keystore.key).to
457-
.equal(data.clientKey)
438+
expect(keystore).to.be.an('object')
439+
expect(keystore).to.have.property('ca')
440+
expect(keystore).to.have.property('cert')
441+
expect(keystore).to.have.property('key')
442+
expect(keystore.ca).to.be.an('array')
443+
expect(keystore.cert).to.be.an('string')
444+
expect(keystore.key).to.be.an('string')
445+
expect(keystore.ca[0]).to.equal(ca.certificate)
446+
expect(keystore.cert).to.equal(data.certificate)
447+
expect(keystore.key).to.equal(data.clientKey)
458448
done()
459449
})
460450
})
@@ -684,10 +674,8 @@ describe('General Tests', function () {
684674

685675
describe('#.checkPkcs12 tests', function () {
686676
it('Check PKCS12 keystore', function (done) {
687-
var pkcs12 = fs.readFileSync(
688-
'./test/fixtures/idsrv3test.pfx')
689-
pem.checkPkcs12(pkcs12, 'idsrv3test', function (error,
690-
result) {
677+
var pkcs12 = fs.readFileSync('./test/fixtures/idsrv3test.pfx')
678+
pem.checkPkcs12(pkcs12, 'idsrv3test', function (error, result) {
691679
hlp.checkError(error)
692680
expect(result).to.be.ok()
693681
done()

test_build_openssl.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,27 @@ tar --strip-components=1 -xzf ${OUT}
4747

4848
case "${LIBRARY}" in
4949
"openssl")
50-
./Configure --prefix=${OPENSSL_DIR} ${OS_COMPILER} -fPIC -g ${OS_FLAGS} no-shared
50+
./Configure --prefix=${OPENSSL_DIR} ${OS_COMPILER} -fPIC -g ${OS_FLAGS} no-shared -static
5151
;;
5252
"libressl")
5353
./configure --prefix=${OPENSSL_DIR} --disable-shared --with-pic
5454
;;
5555
esac
5656

5757
make -j$(nproc)
58-
sudo make install
58+
sudo make install_sw
59+
60+
case "${LIBRARY}" in
61+
"openssl")
62+
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
63+
;;
64+
"libressl")
65+
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
66+
;;
67+
esac
68+
69+
sudo chmod -Rf 0755 /openssl
70+
5971
cd ${NORMALPATH}
72+
73+
rm -r -f node_modules && npm i

0 commit comments

Comments
 (0)