mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 246 forks source link

FTPS on tls, using port 990 #153

Open mybeez opened 8 years ago

mybeez commented 8 years ago

Hello,

I'm trying to connect using the implicit secure option with port 990. Here my configuration:

_connectionProperties.secure = true;

 _connectionProperties.secureOptions = {

    'rejectUnauthorized': false

 };

I've tried with with option 'implicit' but it don't works. Nothing happens. Is-it possible to use implicit over TLS with node-ftp ?

Thanks !

tinydogio-joshua commented 8 years ago

Were you able to get an answer to this or figure it out? I am having a similar issue.

aredfox commented 7 years ago

True - same issues here. I also haven't found any docs on the secureOptions object we can set - or is there docs that I haven't found yet?

aredfox commented 7 years ago

Ok, sorry found docs: https://nodejs.org/api/tls.html#tls_tls_connect_options_callback

Gander7 commented 7 years ago

EDIT: Still an issue in master, fixed in next comment

Anyone find a solution? If I use secure:true, it will finish the onconnect function, do nothing for a few minutes, emit end, and then emit close(had_err = false). It will never emit ready. Function reentry which emits ready is never run. If I use secure: implicit, then I get a timeout while connecting to server.

Gander7 commented 7 years ago

I used the connection.js file from kellym's fork (as suggested on reedit here) and it was able to emit a ready state with an error.

Gander7 commented 7 years ago

My issue was port 990 and using secure: implicit (implicit FTP over TLS). You can change it and use FTPES(explicit FTP over TLS) without reconfiguration of your ftp server. The trick is to use port 21 for FTPES with secure: true and options below. secure: true cannot work with port 990 at this point in time. secure: implicit with port 990 does not work and even kellym's fork throws a protection level error for me.

Working Code:

var Client = require('ftp')
var fs = require('fs')

var c = new Client();
let file = fs.createReadStream(path + filename)
c.on('ready', () => {
  c.put(path + filename,
        '/destination/' + filename, (err) => {
          if (err) throw err;
          c.end()
        })
  })
})

c.connect({
  host: '999.999.999.999',
  user: 'user',
  port: 21,
  password: 'pass',
  secure: true,
  secureOptions: { rejectUnauthorized: false }
});
diegodubon commented 6 years ago

Nice Gander7 it works for me, thanks.