Skip to content

Commit

Permalink
Merge pull request #3 from CinCoders/feature/RES-12
Browse files Browse the repository at this point in the history
add logic to check whether the CA certificate exists
  • Loading branch information
dcruzb authored Oct 23, 2023
2 parents 0ac1be9 + 073654e commit 79f3f60
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@ import { AppDataSource } from './app.datasource';
async function bootstrap() {
let options = {};
if (process.env.NODE_ENV === 'production') {
let httpsOptions = {};
httpsOptions = {
key: fs.readFileSync(
path.join(__dirname, '..', './certs/certificate.key'),
),
cert: fs.readFileSync(
path.join(__dirname, '..', './certs/certificate.crt'),
),
ca: fs.readFileSync(
path.join(__dirname, '..', './certs/intermediate.pem'),
),
};
const httpsOptions: {
key?: Buffer | null;
cert?: Buffer | null;
ca?: Buffer | null;
} = {};

httpsOptions.key = fs.readFileSync(
path.join(__dirname, '..', './certs/certificate.key'),
);
httpsOptions.cert = fs.readFileSync(
path.join(__dirname, '..', './certs/certificate.crt'),
);
const caCertificatePath = path.join(
__dirname,
'..',
'./certs/intermediate.pem',
);
if (fs.existsSync(caCertificatePath)) {
httpsOptions.ca = fs.readFileSync(caCertificatePath);
}
options = { ...options, httpsOptions };
}

Expand Down

0 comments on commit 79f3f60

Please sign in to comment.