与http模块差不多一样
    区别就是https创建服务时需要将私钥与公钥当做参数
    代码如下

    1. const server = https.createServer(
    2. {
    3. key: fs.readFileSync(path.resolve(__dirname, "./server-key.pem")), //私钥
    4. cert: fs.readFileSync(path.resolve(__dirname, "./server-cert.crt")) // 服务器公钥
    5. },
    6. handler
    7. );