2017-01-03 22:16:48 +01:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 18:13:38 +01:00
|
|
|
const common = require('../common');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
// Verify that detailed getPeerCertificate() return value has all certs.
|
2015-03-04 02:11:21 +01:00
|
|
|
|
2016-12-01 18:13:38 +01:00
|
|
|
const join = require('path').join;
|
2016-12-17 16:05:45 +01:00
|
|
|
const {
|
|
|
|
assert, connect, debug, keys
|
2017-03-01 08:16:48 +01:00
|
|
|
} = require(join(common.fixturesDir, 'tls-connect'));
|
2011-08-26 13:00:40 +02:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
connect({
|
|
|
|
client: {rejectUnauthorized: false},
|
|
|
|
server: keys.agent1,
|
|
|
|
}, function(err, pair, cleanup) {
|
|
|
|
assert.ifError(err);
|
|
|
|
const socket = pair.client.conn;
|
|
|
|
let peerCert = socket.getPeerCertificate();
|
|
|
|
assert.ok(!peerCert.issuerCertificate);
|
2011-08-26 13:00:40 +02:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
peerCert = socket.getPeerCertificate(true);
|
|
|
|
debug('peerCert:\n', peerCert);
|
2014-04-17 13:57:36 +02:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
assert.ok(peerCert.issuerCertificate);
|
|
|
|
assert.strictEqual(peerCert.subject.emailAddress, 'ry@tinyclouds.org');
|
|
|
|
assert.strictEqual(peerCert.serialNumber, '9A84ABCFB8A72AC0');
|
|
|
|
assert.strictEqual(peerCert.exponent, '0x10001');
|
|
|
|
assert.strictEqual(
|
|
|
|
peerCert.fingerprint,
|
|
|
|
'8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA'
|
|
|
|
);
|
|
|
|
assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'],
|
|
|
|
[ 'http://ocsp.nodejs.org/' ]);
|
2014-04-17 13:57:36 +02:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
const issuer = peerCert.issuerCertificate;
|
|
|
|
assert.strictEqual(issuer.issuerCertificate, issuer);
|
|
|
|
assert.strictEqual(issuer.serialNumber, '8DF21C01468AF393');
|
2014-04-17 13:57:36 +02:00
|
|
|
|
2016-12-17 16:05:45 +01:00
|
|
|
return cleanup();
|
|
|
|
});
|