• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Orckestra / orc-scripts / 101621

11 Feb 2025 06:59PM UTC coverage: 34.491%. First build
101621

Pull #1265

Azure Pipelines

orck-adrouin
Use custom certificate for local development

 #79518
Pull Request #1265: Use custom certificate for local development

153 of 431 branches covered (35.5%)

Branch coverage included in aggregate %.

0 of 22 new or added lines in 1 file covered. (0.0%)

274 of 807 relevant lines covered (33.95%)

4.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/scripts/start.js
1
const DevServer = require("webpack-dev-server");
×
2
const webpack = require("webpack");
×
NEW
3
const path = require("path");
×
NEW
4
const fs = require("fs");
×
5

6
const HOST = process.env.HOSTNAME || "localhost";
×
7

8
const args = process.argv.slice(2);
×
9
const argPort = args.indexOf("--port") !== -1 ? args[args.indexOf("--port") + 1] : null;
×
10
const PORT = argPort || process.env.PORT || 5000;
×
11

NEW
12
const findSslPasswordFromParametersFile = (certFile) => {
×
13
        // reference: https://hals.app/blog/recursively-read-parent-folder-nodejs/
14

NEW
15
        let parentDirectory = path.dirname(certFile);
×
NEW
16
        while (fs.existsSync(parentDirectory)) {
×
NEW
17
                console.log("Looking for certificate password in: " + parentDirectory)
×
NEW
18
                const fileToFindPath = path.join(parentDirectory, "parameters.dev.xml");
×
NEW
19
                if (fs.existsSync(fileToFindPath)) {
×
NEW
20
                        const fileContent = fs.readFileSync(fileToFindPath, "utf8");
×
21

22
                        // Using regex to parse the XML to avoid adding a dependency on an XML package
23

NEW
24
                        const matchResult = /<param\s+name="SSL_CertificatePfxPassword"\s+value="(?<Value>[^"]+)"\s*\/>/.exec(fileContent);
×
NEW
25
                        if (matchResult && matchResult.groups && matchResult.groups['Value']) {
×
NEW
26
                                console.log("Certificate password found");
×
NEW
27
                                return matchResult.groups['Value'];
×
28
                        }
29

NEW
30
                        console.warn("Could not find SSL_CertificatePfxPassword in file " + fileToFindPath)
×
NEW
31
                        return null;
×
32
                }
33

34
                // The trick is here:
35
                // Using path.dirname() of a directory returns the parent directory!
NEW
36
                const parentDirname = path.dirname(parentDirectory);
×
37
                // But only to a certain point (file system root) (So to avoid infinite loops lets stop here)
NEW
38
                if (parentDirectory === parentDirname) {
×
NEW
39
                        return null;
×
40
                }
41

NEW
42
                parentDirectory = parentDirname;
×
43
        }
44

NEW
45
        return null;
×
46
}
47

48
const config = require("../config/webpack.config.js");
×
49
const options = {
×
50
        historyApiFallback: true,
51
        hot: "only",
52
        port: PORT,
53
        host: HOST,
54
        static: './dist',
55
        devMiddleware: {
56
                publicPath: process.env.WEBPACK_PUBLIC_PATH || "/",
×
57
        },
58
};
59

60
if (HOST !== "localhost" || args.indexOf("--https") !== -1 || process.env.HTTPS) {
×
61
        options.server = 'https';
×
62
}
63

NEW
64
if (options.server === 'https' && process.env.SSL_CERT_PATH) {
×
NEW
65
        options.server = {
×
66
                type: 'https',
67
                options: {
68
                        pfx: process.env.SSL_CERT_PATH,
69
                        passphrase: process.env.SSL_CERT_PASSWORD || findSslPasswordFromParametersFile(process.env.SSL_CERT_PATH),
×
70
                },
71
        }
72
}
73

74
const compiler = webpack(config);
×
75

76
const server = new DevServer(options, compiler);
×
77

78
(async () => {
×
79
        await server.start();
×
80
})();
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc