From d1a02c0da535433a6d655f4ea5b0894260eb8718 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Tue, 21 Jun 2022 02:08:43 +0500 Subject: [PATCH] chore: debugging certs --- api/src/server.ts | 4 ++-- api/src/utils/getCertificates.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/src/server.ts b/api/src/server.ts index 3745169..0743469 100644 --- a/api/src/server.ts +++ b/api/src/server.ts @@ -16,9 +16,9 @@ appPromise.then(async (app) => { ) }) } else { - const { key, cert } = await getCertificates() + const { key, cert, ca } = await getCertificates() - const httpsServer = createServer({ key, cert }, app) + const httpsServer = createServer({ key, cert, ca }, app) httpsServer.listen(sasJsPort, () => { console.log( `⚡️[server]: Server is running at https://localhost:${sasJsPort}` diff --git a/api/src/utils/getCertificates.ts b/api/src/utils/getCertificates.ts index e1e96e7..5cbd953 100644 --- a/api/src/utils/getCertificates.ts +++ b/api/src/utils/getCertificates.ts @@ -2,18 +2,21 @@ import path from 'path' import { fileExists, getString, readFile } from '@sasjs/utils' export const getCertificates = async () => { - const { PRIVATE_KEY, FULL_CHAIN } = process.env + const { PRIVATE_KEY, FULL_CHAIN, CA } = process.env const keyPath = PRIVATE_KEY ?? (await getFileInput('Private Key (PEM)')) const certPath = FULL_CHAIN ?? (await getFileInput('Full Chain (PEM)')) + const caPath = CA ?? (await getFileInput('Full Chain (PEM)')) console.log('keyPath: ', keyPath) console.log('certPath: ', certPath) + console.log('caPath: ', caPath) const key = await readFile(keyPath) const cert = await readFile(certPath) + const ca = await readFile(caPath) - return { key, cert } + return { key, cert, ca } } const getFileInput = async (filename: string): Promise => {