blob: ff9806cdb026145ed927870f638b5cfed2f38da4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
'use strict';
var common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
return;
}
var tls = require('tls');
var fs = require('fs');
var options = {
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
};
var cert = null;
var server = tls.createServer(options, function(conn) {
conn.end('ok');
}).listen(common.PORT, function() {
var c = tls.connect(common.PORT, {
rejectUnauthorized: false
}, function() {
c.on('end', common.mustCall(function() {
c.end();
server.close();
}));
c.on('data', function(data) {
assert.equal(data, 'ok');
});
cert = c.getPeerCertificate();
});
});
process.on('exit', function() {
assert(cert);
assert.equal(cert.subject.C, 'US');
});
|