Tuesday, 23 May 2017

POST Request Issue using certificate

I am trying to make a post request using certificate to external server External server requires a certificate but it responded with the error below

CODE:


var request = require('request');


 request({
  method: "POST",
  uri: "195.x.x.x:5099/x",
  headers: {
    "Content-Type": "application/json"
  },
  body: Args,
      checkServerIdentity: function (host, cert) {

    return undefined;
  },
  agentOptions: {
    ca: "cert.cert"
  }
}, function(error, httpResponse, body) {
      console.log(httpResponse);
  //handle response
      if(error) console.log('Error:', error);

 console.log("Body-parser:", body);

      callback(body);
});


Error:


Error: { Error: read ECONNRESET
    at exports._errnoException (util.js:1022:11)
    at TLSWrap.onread (net.js:572:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
Body-parser: undefined
PostResult: undefined



via tyehia

No comments:

Post a Comment