与http模块差不多一样区别就是https创建服务时需要将私钥与公钥当做参数代码如下 const server = https.createServer( { key: fs.readFileSync(path.resolve(__dirname, "./server-key.pem")), //私钥 cert: fs.readFileSync(path.resolve(__dirname, "./server-cert.crt")) // 服务器公钥 }, handler);