icetee / node-ftp

An FTP client module for node.js
MIT License
25 stars 16 forks source link

Fix secure implicit connections in pasv mode #18

Closed scagood closed 4 years ago

scagood commented 4 years ago

This issue occurs when you set secure to 'implicit'.

Here is a minimum viable example of the error in action:

client.js:

const fs = require('fs');
const Client = require('@icetee/ftp');

const client = new Client();

client.on('ready', async () => {
    client.list((error, list) => {
        console.info(error || list);
        client.end();
    });
});

client.connect({
    host: 'localhost',
    port: 9876,
    secure: 'implicit',
    secureOptions: {ca: [fs.readFileSync('crts/rootCA.crt')]},
});

server.js:

const fs = require('fs');
const FtpServer = require('ftp-srv');

const server = new FtpServer({
    url: 'ftps://127.0.0.1:9876',
    pasv_url: '0.0.0.0',
    tls: {
        cert: fs.readFileSync('crts/server.crt'),
        key: fs.readFileSync('crts/server.key'),
        ca: fs.readFileSync('crts/rootCA.crt'),
    },
});

server.on('login', ({}, resolve) => resolve({}));

server.listen();

I think this may be related to this issue, at that was the symptom that this caused for me :eyes: https://github.com/trs/ftp-srv/issues/192

scagood commented 4 years ago

Not too sure why the CI build was not linked here :thinking: https://travis-ci.org/github/icetee/node-ftp/builds/688979374

scagood commented 4 years ago

@icetee Is there anything I can do to push this PR forward? Im currently patching this as a post install script :sweat_smile:

scagood commented 4 years ago

I assume that this is not wanted :eyes: