My node.js https client always works regardless of certificate validity

后端 未结 4 919
再見小時候
再見小時候 2020-12-09 23:22

This test program connects to an https server and gets some content. I\'ve checked my server in browsers and with curl and the certificate is working correctly. If I run cur

4条回答
  •  不思量自难忘°
    2020-12-09 23:47

    I do this in npm, using the request module. It goes like this:

    var cacert = ... // in npm, this is a config setting
    var request = require("request")
    request.get({ url: "https://...",
                  ca: cacert,
                  strictSSL: true })
      .on("response", function (resp) { ... })
      .on("error", function (er) { ... })
    

    The error event will be raised if the ssl isn't valid.

提交回复
热议问题