Files
outline/server/utils/ssl.ts
codegen-sh[bot] 758d4edbb9 Upgrade @typescript-eslint dependencies to v8.33.0 (#9363)
* Upgrade @typescript-eslint dependencies from v6.21.0 to v8.33.0

- Updated @typescript-eslint/eslint-plugin from ^6.21.0 to ^8.33.0
- Updated @typescript-eslint/parser from ^6.21.0 to ^8.33.0
- Tested linting functionality to ensure compatibility
- This brings the latest TypeScript ESLint features and bug fixes

* lint

* tsc

---------

Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2025-06-01 11:01:15 -04:00

45 lines
1.1 KiB
TypeScript

import fs from "fs";
import path from "path";
import env from "../env";
/**
* Find if SSL certs are available in the environment or filesystem and return
* as a valid ServerOptions object
*/
export function getSSLOptions() {
function safeReadFile(name: string) {
try {
return fs.readFileSync(
path.normalize(`${__dirname}/../../../${name}`),
"utf8"
);
} catch (_err) {
return undefined;
}
}
try {
return {
key:
(env.SSL_KEY
? Buffer.from(env.SSL_KEY, "base64").toString("ascii")
: undefined) ||
safeReadFile("private.key") ||
safeReadFile("private.pem") ||
safeReadFile("server/config/certs/private.key"),
cert:
(env.SSL_CERT
? Buffer.from(env.SSL_CERT, "base64").toString("ascii")
: undefined) ||
safeReadFile("public.cert") ||
safeReadFile("public.pem") ||
safeReadFile("server/config/certs/public.cert"),
};
} catch (_err) {
return {
key: undefined,
cert: undefined,
};
}
}