node-js-libs/curlrequest

Support for 2 Factor Auth for WebDAV (passing certificate + passphrase)?

Closed this issue · 3 comments

I was looking at #43 but I'm not sure if this is related or not. I was wondering if its possible to specify an SSL certificate and it's passphrase when making a curl connection to a WebDAV server.

If you look at this article:

http://www.qed42.com/blog/using-curl-webdav-two-factor-authentication

It shows exactly how to do this on the command line. I just tested this on OSX and it worked perfectly. You specify an SSL certificate and it's keyphrase/passphrase along with the typical username/password when making the connection.

Is the same thing is possible with this library? Can you pass the cert and passphrase as curl options or something?

This library is just a thin wrapper around the command line interface. Any options you pass to the library are passed directly to curl (along with some defaults).

You can see the command that was executed by inspecting the third argument:

> var curl = require('curlrequest')
undefined
> curl.request({ url: 'http://httpbin.org/get' }, function (err, response, meta) { 
... console.log(meta);
... });
undefined
> { cmd: 'curl',
  args: 
   [ '--silent',
     '--show-error',
     '--no-buffer',
     '--globoff',
     '--url',
     'http://httpbin.org/get',
     '--location',
     '--max-redirs',
     3,
     '--header',
     'Accept: */*',
     '--header',
     'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3',
     '--header',
     'Accept-Language: en-US,en;q=0.8',
     '--user-agent',
     'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6' ],
  time: 1013 }

I'm not sure about the options required to support your specific use-case, but you should be able to play around with library options until you get it right.

Okay thanks I will mess around with it. So when I specify an option, like the --cert option do I just do:

var options = {
  "url": "https://www.google.com",
  "cert": "mycert.p12:mypassphrase"
};

Like that? Just take whatever the cURL command line option is (https://curl.haxx.se/docs/manpage.html) and remove the double-dashes? Sorry its just not 100% clear to me on how to specify options just yet. Thank you!

That's right. Options are passed like {"user-agent": "foo bar"} and flags are passed like {"ipv4": true}