Skip to content

Commit 7efa7c8

Browse files
committed
rename ssl client certs options into --ssl-client-cert-list and add an example of ssl client cert list
1 parent e547143 commit 7efa7c8

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ Newman supports SSL client certificates, via the following CLI options (availabl
221221

222222
#### Use a ssl client certificates configuration file (supports multiple certificates per run)
223223

224-
- --ssl-client-certs<br/>
225-
The path to the ssl client certs configuration file (json format). See [examples/multiple-ssl-client-certs.json](https://github.com/postmanlabs/newman/blob/develop/examples/multiple-ssl-client-certs.json)
224+
- --ssl-client-cert-list<br/>
225+
The path to the ssl client certificate list configuration file (json format). See [examples/ssl-client-cert-list.json](https://github.com/postmanlabs/newman/blob/develop/examples/ssl-client-cert-list.json)
226226
This option allows multiple ssl client certificiates and different ssl client certificate per url or hostname.
227227
This option and --ssl-client-cert, --ssl-client-key and --ssl-client-passphrase are exclusives.
228228

bin/newman.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ program
5252
.option('--timeout-script [n]', 'Specify a timeout for script (in milliseconds).', util.cast.integer, 0)
5353
.option('--ignore-redirects', 'If present, Newman will not follow HTTP Redirects.')
5454
.option('-k, --insecure', 'Disables SSL validations.')
55-
.option('--ssl-client-certs <path>',
55+
.option('--ssl-client-cert-list <path>',
5656
'Specify the path to the Client SSL certificates configuration file (json format).' +
5757
'\nThis option different ssl client certificate per url/hostname.' +
5858
'\nThis option and --ssl-client-cert, --ssl-client-key and --ssl-client-passphrase are exclusives.')

examples/ssl-client-cert-list.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"name": "domain1",
4+
"matches": ["https://test.domain1.com/*", "https://www.domain1/*"],
5+
"key": {"src": "./client.domain1.key"},
6+
"cert": {"src": "./client.domain1.crt"},
7+
"passphrase": "changeme"
8+
},
9+
{
10+
"name": "domain2",
11+
"matches": ["https://domain2.com/*"],
12+
"key": {"src": "./client.domain2.key"},
13+
"cert": {"src": "./client.domain2.crt"},
14+
"passphrase": "changeme"
15+
}
16+
]

lib/run/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,29 @@ module.exports = function (options, callback) {
136136
// to store the exported content from reporters
137137
emitter.exports = [];
138138

139-
let secureFileResolver, sslClientCerts;
139+
let secureFileResolver, sslClientCertList;
140140

141141
secureFileResolver = new SecureFS(options.workingDir, options.insecureFileRead);
142-
sslClientCerts = [];
142+
sslClientCertList = [];
143143

144-
if (options.sslClientCert && options.sslClientCerts) {
144+
if (options.sslClientCert && options.sslClientCertList) {
145145
err = 'newman: too many ssl client cert options: use only one of them.';
146146

147147
return callback(new Error(err));
148148
}
149149

150150
// new client certificate option that manages client certificate <-> url mapping
151-
if (options.sslClientCerts) {
151+
if (options.sslClientCertList) {
152152
try {
153-
sslClientCerts = JSON.parse(secureFileResolver.readFileSync(options.sslClientCerts));
153+
sslClientCertList = JSON.parse(secureFileResolver.readFileSync(options.sslClientCertList));
154154
}
155155
catch (error) {
156156
return callback(new Error('newman: unable to read the ssl client certificates file'));
157157
}
158158
}
159159
// keeping this option to pass one client certificate for all urls
160160
if (options.sslClientCert) {
161-
sslClientCerts = [{
161+
sslClientCertList = [{
162162
name: 'client-cert',
163163
matches: [sdk.UrlMatchPattern.MATCH_ALL_URLS],
164164
key: { src: options.sslClientKey },
@@ -193,8 +193,8 @@ module.exports = function (options, callback) {
193193
timings: Boolean(options.verbose),
194194
extendedRootCA: options.sslExtraCaCerts
195195
},
196-
certificates: (options.sslClientCerts || options.sslClientCert) &&
197-
new sdk.CertificateList({}, sslClientCerts)
196+
certificates: (options.sslClientCertList || options.sslClientCert) &&
197+
new sdk.CertificateList({}, sslClientCertList)
198198
}, function (err, run) {
199199
if (err) { return callback(err); }
200200

test/cli/ssl-client-cert.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ describe('SSL Client certificates', function () {
6565

6666
it('should not work when both client certificate options are used', function (done) {
6767
// eslint-disable-next-line max-len
68-
exec('node ./bin/newman.js run test/fixtures/run/multiple-ssl-client-certs.json --ssl-client-certs test/fixtures/ssl/sslClientCerts.json --ssl-client-cert test/fixtures/ssl/client.crt --ssl-client-key test/fixtures/ssl/client.key --ssl-client-passphrase password -k', function (code) {
68+
exec('node ./bin/newman.js run test/fixtures/run/ssl-client-cert-list.json --ssl-client-cert-list test/fixtures/ssl/sslClientCertList.json --ssl-client-cert test/fixtures/ssl/client.crt --ssl-client-key test/fixtures/ssl/client.key --ssl-client-passphrase password -k', function (code) {
6969
expect(code, 'should have exit code different than 0').to.not.equal(0);
7070
done();
7171
});
7272
});
7373

7474
it('should work correctly with multiple client certificates', function (done) {
7575
// eslint-disable-next-line max-len
76-
exec('node ./bin/newman.js run test/fixtures/run/multiple-ssl-client-certs.json --verbose --ssl-client-certs ./test/fixtures/ssl/sslClientCerts.json -k', function (code) {
76+
exec('node ./bin/newman.js run test/fixtures/run/ssl-client-cert-list.json --verbose --ssl-client-cert-list ./test/fixtures/ssl/sslClientCertList.json -k', function (code) {
7777
expect(code, 'should have exit code of 0').to.equal(0);
7878
done();
7979
});

test/library/ssl-client-cert.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ describe('SSL Client certificates', function () {
6565

6666
it('should work correctly with multiple client certificates', function (done) {
6767
newman.run({
68-
collection: 'test/fixtures/run/multiple-ssl-client-certs.json',
69-
sslClientCerts: 'test/fixtures/ssl/sslClientCerts.json',
68+
collection: 'test/fixtures/run/ssl-client-cert-list.json',
69+
sslClientCertList: 'test/fixtures/ssl/sslClientCertList.json',
7070
insecure: true
7171
}, done);
7272
});

0 commit comments

Comments
 (0)