mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-04 14:37:34 +00:00
Implement Let's Encrypt IP certificate support with async/await
- Refactor `CertificateManager` to use a factory function (`createCertificateManager`) for dependency injection of the ACME client. - Update `main.ts` to use `async/await` within an IIFE for cleaner initialization of the certificate manager, handling errors gracefully without blocking startup. - Remove unused dependencies (`node-fetch`, `mkdirp`) from `src/shadowbox`. - Ensure correct ACME client usage (v5 API). - Update `install_server.sh` to grant write permissions to the persisted state directory for certificate updates. - Update Node.js engine requirement to `>=18.0.0` for `crypto.X509Certificate` support.
This commit is contained in:
parent
2ea358013b
commit
daf88dae61
1 changed files with 17 additions and 12 deletions
|
|
@ -241,19 +241,24 @@ async function main() {
|
|||
});
|
||||
|
||||
// Do not await this, so the server starts even if certificate generation takes time or fails
|
||||
createCertificateManager(
|
||||
proxyHostname,
|
||||
certificateFilename,
|
||||
privateKeyFilename,
|
||||
process.env.SB_STATE_DIR || DEFAULT_STATE_DIR,
|
||||
(context: tls.SecureContext) => {
|
||||
// Access the underlying node server to update the secure context
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(apiServer.server as any).setSecureContext(context);
|
||||
(async () => {
|
||||
try {
|
||||
const certificateManager = await createCertificateManager(
|
||||
proxyHostname,
|
||||
certificateFilename,
|
||||
privateKeyFilename,
|
||||
process.env.SB_STATE_DIR || DEFAULT_STATE_DIR,
|
||||
(context: tls.SecureContext) => {
|
||||
// Access the underlying node server to update the secure context
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(apiServer.server as any).setSecureContext(context);
|
||||
}
|
||||
);
|
||||
await certificateManager.start();
|
||||
} catch (error) {
|
||||
logging.error(`Failed to initialize CertificateManager: ${error}`);
|
||||
}
|
||||
).then((certificateManager) => {
|
||||
certificateManager.start();
|
||||
});
|
||||
})();
|
||||
|
||||
// Pre-routing handlers
|
||||
const cors = corsMiddleware({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue