danwrong / restler

REST client library for node.js
MIT License
1.99k stars 391 forks source link

Client Certificate Support #197

Open thepatron opened 9 years ago

thepatron commented 9 years ago

Hi,

I need to implement client certificates in our application. The current build of 3.2.2 does not support this and required me to modify a few options in the request setup. Can you please include this in future builds so that the client can specify the following options: passphrase, pfx, ca, key, crt.

Just in case anyone else needs to search this issue: node restler client certificate.

Thanks

this.request = proto.request({ host: this.url.hostname, port: this.url.port, path: this._fullPath(), method: this.options.method, headers: this.headers, rejectUnauthorized: this.options.rejectUnauthorized, passphrase: this.options.passphrase, pfx: this.options.pfx, ca: this.options.ca, key: this.options.key, cert: this.options.cert });

Example:

options = { key: fs.readFileSync('../path/to/key.key'), cert: fs.readFileSync('../path/to/cert.crt'), ca: [fs.readFileSync('../path/to/clientcert.crt')], passphrase: 'mypass' };

// or

options = { pfx: fs.readFileSync('../path/to/pfx.pfx'), passphrase: 'mypass' }

json = { myData: 'topost' };

url = 'https://myurl.com';

return restler.postJson(url, json, options).on("complete", (function(_this) { return function(resResponse) { console.log(resResponse) }); }; }));

geetika-kathuria commented 7 years ago

IS this issue addressed?