mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
'use strict';
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
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();
|
|
|