使用节点js请求强制Tls 1.2

时间:2019-04-07 13:49:59

标签: node.js request tls1.2

发送以下请求时:

   let url = "https://pci.zcredit.co.il/WebControl/RequestToken.aspx";
    try {
      request.post({url: url, form: { 
        TerminalNumber: "0882016026",
        Username: "zcemv7",
        PaymentSum: ctx.params._id,
       }}, function(err,response,body){
        console.log(err,response);
       })

    } catch (err) {
      console.log(err);
    }

我遇到了错误:

Error: Client network socket disconnected before secure TLS connection was established
    at TLSSocket.onConnectEnd (_tls_wrap.js:1159:19)
    at Object.onceWrapper (events.js:273:13)
    at TLSSocket.emit (events.js:187:15)
    at TLSSocket.EventEmitter.emit (domain.js:441:20)
    at endReadableNT (_stream_readable.js:1098:12)
    at process.internalTickCallback (internal/process/next_tick.js:72:19)
  code: 'ECONNRESET',
  path: null,
  host: 'pci.zcredit.co.il',
  port: 443,
  localAddress: undefined }

网站api告诉我,我需要强制进行tls 1.2连接,所以我尝试了:

let url = "https://pci.zcredit.co.il/WebControl/RequestToken.aspx";
    try {
      request.post({url: url, agentOptions: {secureProtocol: "TLSv1_2_method"}, form: { 
        TerminalNumber: "0882016026",
        Username: "zcemv7",
        PaymentSum: ctx.params._id,
       }}, function(err,response,body){
        console.log(err,response);
       })

    } catch (err) {
      console.log(err);
    }

我添加了agentOptions:{secureProtocol:“ TLSv1_2_method”},但仍然收到相同的错误。我在这里想念什么吗?还是该错误可能指向除强制tls 1.2之外我还必须纠正的另一件事?

预先感谢

0 个答案:

没有答案