How to use soap client over HTTPS with a self-signed certificate?

2,508 views
Skip to first unread message

Eric

unread,
Aug 30, 2012, 10:33:34 AM8/30/12
to nod...@googlegroups.com
Hi Guys,

My node.js app needs to tal with a webservice using soap over HTTPS connection but using his own SSL certificate (self-signed certificate). In other languages like java all I need to do is import the PEM file into the JRE keystore to make it trusted, and when the soap clients communicate with the webservice everything goes fine.

I can't seem to figure out however how should I do this in node.js. Where is the keystore used by node.js?

Thanks for any help,

Eric

Ben Noordhuis

unread,
Aug 30, 2012, 11:42:32 AM8/30/12
to nod...@googlegroups.com
Take a look at the documentation for https.request() and
tls.connect(). You pass the certificate in an options object, e.g.

var options = url.parse('https://example.com/');
options.cert = fs.readFileSync('example.pem');
var req = https.request(options, cb);

Bernardo Vieira

unread,
Aug 30, 2012, 12:01:22 PM8/30/12
to nod...@googlegroups.com
Don't forget to specify an agent of explicitly set agent = false. If you don't the global agent will be used and your certificate will be ignored. There's a note about that behavior in http://nodejs.org/api/https.html#https_https_request_options_callback but I recently overlooked that and it took me a while to figure out what was going wrong.


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply all
Reply to author
Forward
0 new messages