-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live renewal of the TLS options #331
base: main
Are you sure you want to change the base?
Conversation
I like it, and you didn't make any assumptions about how the user of the library should call it - awesome. I don't see the readme update, does it need to be pushed to this branch still? |
@matt-forster, |
README.md
Outdated
@@ -403,6 +403,23 @@ __Used in:__ `SITE CHMOD` | |||
Returns a unique file name to write to. Client requested filename available if you want to base your function on it. | |||
__Used in:__ `STOU` | |||
|
|||
#### [`renewTlsOptions(tlsOptions)`](src/fs.js#L172) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an instance interface - so not quite the same as the above functions, which are filesystem specific.
I would actually insert a new section here, under API and above CLI;
<!-- Line 163 -->
## [`#renewTlsOptions(tlsOptions)`](src/fs.js#L172)
Used to read and use a new set of TLS certificates without restarting the server.
Receives the same options as the [tls parameter](#tls) parameter in the constructor.
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matt-forster
That makes sense. I have moved it now to a separate section, and made two other changes:
- The section header is now no link (to the source) anymore, because all other header titles were also no links. And otherwise it looked very weird...
- The link pointed to the wrong source file.
Dear,
When working with FTPS, a keypair (private key and certificate) are being passed to the server constructor. Which means you need to restart the server every time the certificate is being renewed.
I use LetsEncrypt certificates for my home automation, which will expire every 3 months. Which means I have to renew the certificate every 3 months, and as a result I need to restart my FTP server every 3 months. Restarting my FTP server only to replace a certificate is not what I want. Because if one of my IP cams is uploading a video recording at that moment, that recording would be lost.
In NodeJs version 11, the setSecureContext function has been added to solve this. By calling this function you can instruct the server to use updated TLS options.
A bit of explanation:
I start my FTP server with the old keypair via the TLS options:
Now I can easily determine which certificate is being used by the FTP server (during the TLS handshake phase), by using this test code to connect to my FTP server:
Which shows that my old (expired) certificate is being used:
Now I tell the server to start using my new certificate (using the new function from this pull request):
When I repeat the test from step 2 again, now indeed I see that my new certificate is used by the server already:
Note that this new certificate will only be used for new connections. For existing connections the old certificate will still being used, since the handshake phase is already finished. So there is no impact on existing connections!
Don't hesitate to ask for extra information or updates!
Bart