Skip to content
Snippets Groups Projects
Commit 21296eb0 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Use generateTLSConfig from toolkit

parent 197f0438
Branches config-cleanup
No related tags found
No related merge requests found
Pipeline #16052 passed
...@@ -14,8 +14,7 @@ import del from 'rollup-plugin-delete'; ...@@ -14,8 +14,7 @@ import del from 'rollup-plugin-delete';
import emitEJS from 'rollup-plugin-emit-ejs' import emitEJS from 'rollup-plugin-emit-ejs'
import {getBabelOutputPlugin} from '@rollup/plugin-babel'; import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import appConfig from './app.config.js'; import appConfig from './app.config.js';
import {getPackagePath, getBuildInfo} from './vendor/toolkit/rollup.utils.js'; import {getPackagePath, getBuildInfo, generateTLSConfig} from './vendor/toolkit/rollup.utils.js';
import {generateTLSConfig} from './rollup.utils.js';
const pkg = require('./package.json'); const pkg = require('./package.json');
const appEnv = (typeof process.env.APP_ENV !== 'undefined') ? process.env.APP_ENV : 'local'; const appEnv = (typeof process.env.APP_ENV !== 'undefined') ? process.env.APP_ENV : 'local';
...@@ -220,7 +219,7 @@ Dependencies: ...@@ -220,7 +219,7 @@ Dependencies:
host: '127.0.0.1', host: '127.0.0.1',
port: 8001, port: 8001,
historyApiFallback: config.basePath + pkg.name + '.html', historyApiFallback: config.basePath + pkg.name + '.html',
https: useHTTPS ? generateTLSConfig() : false, https: useHTTPS ? await generateTLSConfig() : false,
headers: { headers: {
'Content-Security-Policy': config.CSP 'Content-Security-Policy': config.CSP
}, },
......
import fs from 'fs';
import selfsigned from 'selfsigned';
/**
* Creates a server certificate and caches it in the .cert directory
*/
export function generateTLSConfig() {
fs.mkdirSync('.cert', {recursive: true});
if (!fs.existsSync('.cert/server.key') || !fs.existsSync('.cert/server.cert')) {
const attrs = [{name: 'commonName', value: 'dbp-dev.localhost'}];
const pems = selfsigned.generate(attrs, {algorithm: 'sha256', days: 9999});
fs.writeFileSync('.cert/server.key', pems.private);
fs.writeFileSync('.cert/server.cert', pems.cert);
}
return {
key: fs.readFileSync('.cert/server.key'),
cert: fs.readFileSync('.cert/server.cert')
}
}
\ No newline at end of file
Subproject commit be243cdd860d8762be4f60ae5a494054ca99b2b3 Subproject commit 43c558436c6a0f66e6bd162cd6f6ce8af1f2fa7c
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment