Skip to content

Commit

Permalink
fix(cert): fixed cert detection - check by files
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanGerbeth committed Aug 18, 2018
1 parent 66a6a27 commit 81b54d7
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions env/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const certInfo = {
key: 'myserver.key',
cert: 'STAR_gp-home_net.crt',
ca: [
'AddTrustExternalCARoot.crt',
'COMODORSAAddTrustCA.crt',
'COMODORSADomainValidationSecureServerCA.crt'
]
};

const { Nuxt, Builder } = require('nuxt');
const app = require('express')();
const fs = require('fs');
Expand Down Expand Up @@ -28,17 +38,16 @@ httpolyglot.createServer(options, app).listen(port, '0.0.0.0', function() {
});

function getOptions(dir) {
if (fs.existsSync(dir)) {
if (
fs.existsSync(path.join(dir, certInfo.key)) &&
fs.existsSync(path.join(dir, certInfo.cert))
) {
return {
key: fs.readFileSync(path.join(dir, 'myserver.key')),
cert: fs.readFileSync(path.join(dir, 'STAR_gp-home_net.crt')),
ca: [
fs.readFileSync(path.join(dir, 'AddTrustExternalCARoot.crt')),
fs.readFileSync(path.join(dir, 'COMODORSAAddTrustCA.crt')),
fs.readFileSync(
path.join(dir, 'COMODORSADomainValidationSecureServerCA.crt')
)
],
key: fs.readFileSync(path.join(dir, certInfo.key)),
cert: fs.readFileSync(path.join(dir, certInfo.cert)),
ca: certInfo.ca.map(ca => {
return fs.readFileSync(path.join(dir, ca));
}),
requestCert: false,
rejectUnauthorized: false
};
Expand Down

0 comments on commit 81b54d7

Please sign in to comment.