help icon indicating copy to clipboard operation
help copied to clipboard

need help understanding the code that sets up SSL certificate config !!!!!

Open Amoud94 opened this issue 8 years ago • 4 comments

I need some help with this code , i really need to understand how does it work , can some one explain it to me please : https://github.com/nodeftpd/nodeftpd/blob/master/test.js#L13-L36

Amoud94 avatar Feb 22 '18 10:02 Amoud94

Can you ask more directed questions? It's not clear to me what's unclear to you. That code loads keys and certificates from disk.

bnoordhuis avatar Feb 22 '18 10:02 bnoordhuis

i found a package for node.js that you can use to create a ftp server , this package have a fille named test.js , the lien that i mentioned in the first, all i want is to understand that part of code for the SSL https://gist.github.com/Amoud94/c530b8859cdb5c3ca7746c407950fd72

Amoud94 avatar Feb 22 '18 11:02 Amoud94

Well, as @bnoordhuis said: "That code loads keys and certificates from disk."

Specifically, its deriving its configuration of which file (containing data for a PEM formatted certificate ; .pem file) to be read for each environment variable KEY_FILE and CERT_FILE, and optionally CA_FILES (where the latter may contain a ':' separated set of files; again PEM formatted certificate(s)). That is essentially self-documented in the 'usage' guidance that this code would emit should either of the two mandatory environment variable configurations not be present:

*** To run as FTPS server,                 ***
***  set "KEY_FILE", "CERT_FILE"           ***
***  and (optionally) "CA_FILES" env vars. ***

The options.tls are those used to establish a TLS server from the core 'tls' module. They are documented here: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options If this is too technical, there are plenty of how-to articles that discuss SSL/TLS and Node.js with examples that you might find helpful and instructive.

shellberg avatar Feb 22 '18 14:02 shellberg

closing as answered, please re-open if you still have outstanding questions.

gireeshpunathil avatar Mar 14 '18 04:03 gireeshpunathil