Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(done => {
if (fs.existsSync(httpsSockPath) === true) {
// try unlink if sock file exists
fs.unlinkSync(httpsSockPath);
}
if (process.env.HTTP2_TEST) {
httpsServer = https.createSecureServer({ key, cert }, app);
} else {
httpsServer = https.createServer({ key, cert }, app);
}
httpsServer.listen(httpsSockPath, done);
});
listen() {
let config=this.config;
if(config.ssl && config.ssl.enable){
let sslOptions={
key: fs.readFileSync(path.resolve(workDirectory,'ssl/privatekey.pem')), // 私钥
cert: fs.readFileSync(path.resolve(workDirectory,'ssl/certificate.pem')) // 公钥
}
const http2 =require('http2');
var sslServer=http2.createSecureServer(sslOptions, this.createHttpHandler());
sslServer.listen(config.ssl.port)
}
const port=this.config["port"];
const server = http.createServer(this.createHttpHandler());
server.listen(port);
}
test('https', (t) => {
const server = http2.createSecureServer({
key: fs.readFileSync(path.join(__dirname, 'test.key')),
cert: fs.readFileSync(path.join(__dirname, 'test.cert'))
})
server.listen(0, () => {
server.unref()
doTests(server, 'https', t.test)
t.end()
})
})
const http2 = require('http2')
const fs = require('fs')
const server = http2.createSecureServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
}, (req, res) => {
res.end('hello')
})
server.on('error', (err) => console.error(err))
server.listen(3000)
function createMyServer(port: number) {
const server = createSecureServer({ key: privateKey, cert: certificate });
const url = `https://localhost:${port}`;
server.addListener('request', request);
server.listen(port);
console.log(`Listen port ${port}...`);
console.log('Available urls:');
console.log(url);
if (args.openUrl) {
opn(url);
}
}