Skip to content

Commit 4e9d541

Browse files
committed
test: add regression test for nodejs#4127
1 parent 564a88b commit 4e9d541

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

test/fixtures/keys/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ agent1-cert.pem: agent1-csr.pem ca1-cert.pem ca1-key.pem
7979
-CAcreateserial \
8080
-out agent1-cert.pem
8181

82+
agent1-pfx.pem: agent1-cert.pem
83+
openssl pkcs12 -export -in agent1-cert.pem -inkey agent1-key.pem -certfile ca1-cert.pem -out agent1-pfx.pem -password pass:sample
84+
8285
agent1-verify: agent1-cert.pem ca1-cert.pem
8386
openssl verify -CAfile ca1-cert.pem agent1-cert.pem
8487

test/fixtures/keys/agent1-pfx.pem

2.38 KB
Binary file not shown.

test/parallel/test-tls-ocsp-callback.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ var constants = require('constants');
2222
var fs = require('fs');
2323
var join = require('path').join;
2424

25-
test({ response: false }, function() {
26-
test({ response: 'hello world' }, function() {
27-
test({ ocsp: false });
28-
});
29-
});
25+
var pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
26+
27+
var tests = [
28+
{ response: false },
29+
{ response: 'hello world' },
30+
{ ocsp: false },
31+
{ pfx: pfx, passphrase: 'sample', response: 'hello pfx' }
32+
];
3033

3134
function test(testOptions, cb) {
3235

@@ -47,6 +50,13 @@ function test(testOptions, cb) {
4750
var ocspResponse;
4851
var session;
4952

53+
if (testOptions.pfx) {
54+
delete options.key;
55+
delete options.cert;
56+
options.pfx = testOptions.pfx;
57+
options.passphrase = testOptions.passphrase;
58+
}
59+
5060
var server = tls.createServer(options, function(cleartext) {
5161
cleartext.on('error', function(er) {
5262
// We're ok with getting ECONNRESET in this test, but it's
@@ -60,6 +70,7 @@ function test(testOptions, cb) {
6070
});
6171
server.on('OCSPRequest', function(cert, issuer, callback) {
6272
++ocspCount;
73+
console.log(cert, issuer);
6374
assert.ok(Buffer.isBuffer(cert));
6475
assert.ok(Buffer.isBuffer(issuer));
6576

@@ -106,3 +117,13 @@ function test(testOptions, cb) {
106117
assert.equal(ocspCount, 1);
107118
});
108119
}
120+
121+
function runTests(i) {
122+
if (i === tests.length) return;
123+
124+
test(tests[i], common.mustCall(function() {
125+
runTests(i + 1);
126+
}));
127+
}
128+
129+
runTests(0);

0 commit comments

Comments
 (0)