Skip to content

Commit 5d54f02

Browse files
meltuhamySpaceK33z
authored andcommitted
Add support for pfx files as ssl connection options (#631)
* Add support for pfx files as ssl connection options * Add real example for pfx option
1 parent 70671ff commit 5d54f02

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

bin/webpack-dev-server.js

+16
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ yargs.options({
9494
describe: "Path to a SSL CA certificate.",
9595
group: SSL_GROUP
9696
},
97+
"pfx": {
98+
type: "string",
99+
describe: "Path to a SSL pfx file.",
100+
group: SSL_GROUP
101+
},
102+
"pfx-passphrase": {
103+
type: "string",
104+
describe: "Passphrase for pfx file.",
105+
group: SSL_GROUP
106+
},
97107
"content-base": {
98108
type: "string",
99109
describe: "A directory or URL to serve HTML content from.",
@@ -233,6 +243,12 @@ function processOptions(wpOpt) {
233243
if(argv["cacert"])
234244
options.ca = fs.readFileSync(path.resolve(argv["cacert"]));
235245

246+
if(argv["pfx"])
247+
options.pfx = fs.readFileSync(path.resolve(argv["pfx"]));
248+
249+
if(argv["pfx-passphrase"])
250+
options.pfxPassphrase = argv["pfx-passphrase"];
251+
236252
if(argv["inline"] === false)
237253
options.inline = false;
238254

examples/https/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ node ../../bin/webpack-dev-server.js --open --https
66

77
A fake certificate is used to enable https.
88

9+
You can provide the following SSL options to override the fake certificate:
10+
11+
* Certificate options e.g. `node ../../bin/webpack-dev-server.js --open --https --cacert=../../ssl/ca.pem --cert=../../ssl/server.crt --key=../../ssl/server.key`
12+
* PFX and Passphrase e.g. `node ../../bin/webpack-dev-server.js --open --https --pfx=./test_cert.pfx --pfx-passphrase=sample`
13+
914
## What should happen
1015

1116
The script should open `https://localhost:8080/`. Your browser will probably give you a warning about using an invalid certificate. After ignoring this warning, you should see "It's working."

examples/https/test_cert.pfx

1.84 KB
Binary file not shown.

lib/Server.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ function Server(compiler, options) {
307307
options.https = {
308308
key: options.key,
309309
cert: options.cert,
310-
ca: options.ca
310+
ca: options.ca,
311+
pfx: options.pfx,
312+
passphrase: options.pfxPassphrase
311313
};
312314
}
313315

0 commit comments

Comments
 (0)