blob: 7e11522f6ddc850e9a242aa952eb12132fbebf7c (
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
43
44
45
46
47
48
49
50
|
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
const tls = require('tls');
crypto.DEFAULT_ENCODING = 'buffer';
const fs = require('fs');
const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
const server = tls.Server(options, (socket) => {
setImmediate(() => {
verify();
setImmediate(() => {
socket.destroy();
});
});
});
function verify() {
crypto.createVerify('RSA-SHA1')
.update('Test')
.verify(certPem, 'asdfasdfas', 'base64');
}
server.listen(0, common.mustCall(() => {
tls.connect({
port: server.address().port,
rejectUnauthorized: false
}, common.mustCall(() => {
verify();
}))
.on('error', common.mustNotCall())
.on('close', common.mustCall(() => {
server.close();
})).resume();
}));
server.unref();
|