2018-09-28 23:17:00 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
const https = require('https')
|
|
|
|
const path = require('path')
|
2018-06-20 07:05:43 +00:00
|
|
|
|
2018-09-28 23:17:00 +00:00
|
|
|
const server = https.createServer({
|
2018-06-20 07:05:43 +00:00
|
|
|
key: fs.readFileSync(path.resolve(__dirname, 'tls.key.pem')),
|
|
|
|
cert: fs.readFileSync(path.resolve(__dirname, 'tls.cert.pem'))
|
|
|
|
}, (req, res) => {
|
|
|
|
res.end(JSON.stringify({ protocol: req.socket.getProtocol() }))
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
server.close()
|
|
|
|
}, 0)
|
|
|
|
})
|
|
|
|
|
|
|
|
server.listen(0, () => {
|
|
|
|
console.log(server.address().port)
|
|
|
|
})
|