diff --git a/backend/config/.env.development.example b/backend/config/.env.development.example index 27cfd48..9da0edd 100644 --- a/backend/config/.env.development.example +++ b/backend/config/.env.development.example @@ -84,4 +84,11 @@ SECURE_COOKIES= # SSL=true # Place your SSL certificate files in the root directory of the project # With the names: certificate.crt, certificate.key, and certificate.ca-bundle; -SSL= \ No newline at end of file +SSL= + +# HTTPS cert paths (optional): If you need to change the paths of the https certs +# You can do so with these env variables. +# By default myDrive looks for certificate.crt, certificate.ca-bundle and certificate.key on the root of the project +HTTPS_KEY_PATH= +HTTPS_CA_PATH= +HTTPS_CRT_PATH= \ No newline at end of file diff --git a/backend/config/.env.production.example b/backend/config/.env.production.example index 27cfd48..9da0edd 100644 --- a/backend/config/.env.production.example +++ b/backend/config/.env.production.example @@ -84,4 +84,11 @@ SECURE_COOKIES= # SSL=true # Place your SSL certificate files in the root directory of the project # With the names: certificate.crt, certificate.key, and certificate.ca-bundle; -SSL= \ No newline at end of file +SSL= + +# HTTPS cert paths (optional): If you need to change the paths of the https certs +# You can do so with these env variables. +# By default myDrive looks for certificate.crt, certificate.ca-bundle and certificate.key on the root of the project +HTTPS_KEY_PATH= +HTTPS_CA_PATH= +HTTPS_CRT_PATH= \ No newline at end of file diff --git a/backend/config/.env.test.example b/backend/config/.env.test.example index 27cfd48..9da0edd 100644 --- a/backend/config/.env.test.example +++ b/backend/config/.env.test.example @@ -84,4 +84,11 @@ SECURE_COOKIES= # SSL=true # Place your SSL certificate files in the root directory of the project # With the names: certificate.crt, certificate.key, and certificate.ca-bundle; -SSL= \ No newline at end of file +SSL= + +# HTTPS cert paths (optional): If you need to change the paths of the https certs +# You can do so with these env variables. +# By default myDrive looks for certificate.crt, certificate.ca-bundle and certificate.key on the root of the project +HTTPS_KEY_PATH= +HTTPS_CA_PATH= +HTTPS_CRT_PATH= \ No newline at end of file diff --git a/backend/enviroment/env.ts b/backend/enviroment/env.ts index dcfbc46..305d661 100644 --- a/backend/enviroment/env.ts +++ b/backend/enviroment/env.ts @@ -31,6 +31,9 @@ export default { ? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT : 0, docker: process.env.DOCKER === "true", + httpsKeyPath: process.env.HTTPS_KEY_PATH, + httpsCaPath: process.env.HTTPS_CA_PATH, + httpsCrtPath: process.env.HTTPS_CRT_PATH, }; module.exports = { @@ -66,4 +69,7 @@ module.exports = { ? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT : 0, docker: process.env.DOCKER === "true", + httpsKeyPath: process.env.HTTPS_KEY_PATH, + httpsCaPath: process.env.HTTPS_CA_PATH, + httpsCrtPath: process.env.HTTPS_CRT_PATH, }; diff --git a/backend/server/server.ts b/backend/server/server.ts index 10dc59d..49d31f5 100755 --- a/backend/server/server.ts +++ b/backend/server/server.ts @@ -23,9 +23,12 @@ let server: any; let serverHttps: any; if (process.env.SSL === "true") { - const cert = fs.readFileSync("certificate.crt"); - const ca = fs.readFileSync("certificate.ca-bundle"); - const key = fs.readFileSync("certificate.key"); + const certPath = env.httpsCrtPath || "certificate.crt" + const caPath = env.httpsCaPath || "certificate.ca-bundle" + const keyPath = env.httpsKeyPath || "certificate.key" + const cert = fs.readFileSync(certPath); + const ca = fs.readFileSync(caPath); + const key = fs.readFileSync(keyPath); const options = { cert,