Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

@matt-forster matt-forster Jun 27, 2022

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.
...

Copy link
Contributor Author

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:

  1. 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...
  2. The link pointed to the wrong source file.

```
let originalOptions = {};
originalOptions.tls = {
key: fs.readFileSync("\path\to\old\key.pem"),
cert: fs.readFileSync("\path\to\old\cert.pem")
}
let ftpServer = new FtpServer(originalOptions);

// Afterwards when the certificate is going to expire, it will need to be renewed
let newTlsOptions = {
key: fs.readFileSync("\path\to\new\key.pem"),
cert: fs.readFileSync("\path\to\new\cert.pem")
}
ftpServer.renewTlsOptions(newTlsOptions);
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,9 @@ class FtpServer extends EventEmitter {
});
}

renewTlsOptions(tlsOptions) {
this.server.setSecureContext(tlsOptions);
this.log.debug('Updating TLS options');
}
}
module.exports = FtpServer;