mscdex / node-ftp

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

Error connecting to sftp #96

Closed paudr closed 10 years ago

paudr commented 10 years ago

When i try to connect to sftp server (with filezilla server) i get the next error: events.js:72 throw er; // Unhandled 'error' event ^ Error: DEPTH_ZERO_SELF_SIGNED_CERT at SecurePair. (tls.js:1367:32) at SecurePair.emit (events.js:92:17) at SecurePair.maybeInitFinished (tls.js:979:10) at CleartextStream.read as _read at CleartextStream.Readable.read (_stream_readable.js:340:10) at EncryptedStream.write as _write at doWrite (_stream_writable.js:225:10) at writeOrBuffer (_stream_writable.js:215:5) at EncryptedStream.Writable.write (_stream_writable.js:182:11) at Socket.ondata (stream.js:51:26)

My connection options is: c.connect({ host: host, port: 21, user: user, password: password, secure: true, debug: console.log });

mscdex commented 10 years ago

You can do one of two things. One solution is to specify the ca in secureOptions if you have a copy of the self-signed CA in PEM format (ideal):

c.connect({
  secureOptions: {
    ca: [ fs.readFileSync('/path/to/ca.pem') ]
  },
  // ...
});

Or you can ignore the warning by disabling rejectUnauthorized:

c.connect({
  secureOptions: {
    rejectUnauthorized: false
  },
  // ...
});

Either way, please try with the master branch and let me know how it goes for you.

paudr commented 10 years ago

Thanks for the answer. It fix the problem.