Skip to content

Commit 05d0a2b

Browse files
authored
BREAKING CHANGE(https): migrate ca, cert, pfx, key, pfx-passphrase, and requestCert to https object (#2564)
1 parent 83d4ec3 commit 05d0a2b

File tree

15 files changed

+128
-505
lines changed

15 files changed

+128
-505
lines changed

bin/cli-flags.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,6 @@ module.exports = {
8484
group: SSL_GROUP,
8585
describe: 'HTTP/2, must be used with HTTPS',
8686
},
87-
{
88-
name: 'key',
89-
type: String,
90-
describe: 'Path to a SSL key.',
91-
group: SSL_GROUP,
92-
},
93-
{
94-
name: 'cert',
95-
type: String,
96-
describe: 'Path to a SSL certificate.',
97-
group: SSL_GROUP,
98-
},
99-
{
100-
name: 'cacert',
101-
type: String,
102-
describe: 'Path to a SSL CA certificate.',
103-
group: SSL_GROUP,
104-
},
105-
{
106-
name: 'pfx',
107-
type: String,
108-
describe: 'Path to a SSL pfx file.',
109-
group: SSL_GROUP,
110-
},
111-
{
112-
name: 'pfx-passphrase',
113-
type: String,
114-
describe: 'Passphrase for pfx file.',
115-
group: SSL_GROUP,
116-
},
11787
{
11888
name: 'content-base',
11989
type: String,

bin/options.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,6 @@ const options = {
9696
group: SSL_GROUP,
9797
describe: 'HTTP/2, must be used with HTTPS',
9898
},
99-
key: {
100-
type: 'string',
101-
describe: 'Path to a SSL key.',
102-
group: SSL_GROUP,
103-
},
104-
cert: {
105-
type: 'string',
106-
describe: 'Path to a SSL certificate.',
107-
group: SSL_GROUP,
108-
},
109-
cacert: {
110-
type: 'string',
111-
describe: 'Path to a SSL CA certificate.',
112-
group: SSL_GROUP,
113-
},
114-
pfx: {
115-
type: 'string',
116-
describe: 'Path to a SSL pfx file.',
117-
group: SSL_GROUP,
118-
},
119-
'pfx-passphrase': {
120-
type: 'string',
121-
describe: 'Passphrase for pfx file.',
122-
group: SSL_GROUP,
123-
},
12499
'content-base': {
125100
type: 'string',
126101
describe: 'A directory or URL to serve HTML content from.',

examples/cli/https/README.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/cli/https/app.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/cli/https/test_cert.pfx

-1.84 KB
Binary file not shown.

examples/cli/https/webpack.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/Server.js

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -578,23 +578,16 @@ class Server {
578578

579579
setupHttps() {
580580
// if the user enables http2, we can safely enable https
581-
if (this.options.http2 && !this.options.https) {
582-
this.options.https = true;
581+
if (
582+
(this.options.http2 && !this.options.https) ||
583+
this.options.https === true
584+
) {
585+
this.options.https = {
586+
requestCert: false,
587+
};
583588
}
584589

585590
if (this.options.https) {
586-
// for keep supporting CLI parameters
587-
if (typeof this.options.https === 'boolean') {
588-
this.options.https = {
589-
ca: this.options.ca,
590-
pfx: this.options.pfx,
591-
key: this.options.key,
592-
cert: this.options.cert,
593-
passphrase: this.options.pfxPassphrase,
594-
requestCert: this.options.requestCert || false,
595-
};
596-
}
597-
598591
for (const property of ['ca', 'pfx', 'key', 'cert']) {
599592
const value = this.options.https[property];
600593
const isBuffer = value instanceof Buffer;
@@ -623,23 +616,6 @@ class Server {
623616

624617
this.options.https.key = this.options.https.key || fakeCert;
625618
this.options.https.cert = this.options.https.cert || fakeCert;
626-
627-
// note that options.spdy never existed. The user was able
628-
// to set options.https.spdy before, though it was not in the
629-
// docs. Keep options.https.spdy if the user sets it for
630-
// backwards compatibility, but log a deprecation warning.
631-
if (this.options.https.spdy) {
632-
// for backwards compatibility: if options.https.spdy was passed in before,
633-
// it was not altered in any way
634-
this.log.warn(
635-
'Providing custom spdy server options is deprecated and will be removed in the next major version.'
636-
);
637-
} else {
638-
// if the normal https server gets this option, it will not affect it.
639-
this.options.https.spdy = {
640-
protocols: ['h2', 'http/1.1'],
641-
};
642-
}
643619
}
644620
}
645621

@@ -648,7 +624,12 @@ class Server {
648624
if (this.options.http2) {
649625
// TODO: we need to replace spdy with http2 which is an internal module
650626
this.listeningApp = require('spdy').createServer(
651-
this.options.https,
627+
{
628+
...this.options.https,
629+
spdy: {
630+
protocols: ['h2', 'http/1.1'],
631+
},
632+
},
652633
this.app
653634
);
654635
} else {

lib/options.json

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,6 @@
1616
"bonjour": {
1717
"type": "boolean"
1818
},
19-
"ca": {
20-
"anyOf": [
21-
{
22-
"type": "string"
23-
},
24-
{
25-
"instanceof": "Buffer"
26-
}
27-
]
28-
},
29-
"cert": {
30-
"anyOf": [
31-
{
32-
"type": "string"
33-
},
34-
{
35-
"instanceof": "Buffer"
36-
}
37-
]
38-
},
3919
"clientLogLevel": {
4020
"enum": [
4121
"info",
@@ -136,10 +116,59 @@
136116
"https": {
137117
"anyOf": [
138118
{
139-
"type": "object"
119+
"type": "boolean"
140120
},
141121
{
142-
"type": "boolean"
122+
"type": "object",
123+
"additionalProperties": false,
124+
"properties": {
125+
"passphrase": {
126+
"type": "string"
127+
},
128+
"requestCert": {
129+
"type": "boolean"
130+
},
131+
"ca": {
132+
"anyOf": [
133+
{
134+
"type": "string"
135+
},
136+
{
137+
"instanceof": "Buffer"
138+
}
139+
]
140+
},
141+
"key": {
142+
"anyOf": [
143+
{
144+
"type": "string"
145+
},
146+
{
147+
"instanceof": "Buffer"
148+
}
149+
]
150+
},
151+
"pfx": {
152+
"anyOf": [
153+
{
154+
"type": "string"
155+
},
156+
{
157+
"instanceof": "Buffer"
158+
}
159+
]
160+
},
161+
"cert": {
162+
"anyOf": [
163+
{
164+
"type": "string"
165+
},
166+
{
167+
"instanceof": "Buffer"
168+
}
169+
]
170+
}
171+
}
143172
}
144173
]
145174
},
@@ -166,16 +195,6 @@
166195
}
167196
]
168197
},
169-
"key": {
170-
"anyOf": [
171-
{
172-
"type": "string"
173-
},
174-
{
175-
"instanceof": "Buffer"
176-
}
177-
]
178-
},
179198
"liveReload": {
180199
"type": "boolean"
181200
},
@@ -242,19 +261,6 @@
242261
}
243262
]
244263
},
245-
"pfx": {
246-
"anyOf": [
247-
{
248-
"type": "string"
249-
},
250-
{
251-
"instanceof": "Buffer"
252-
}
253-
]
254-
},
255-
"pfxPassphrase": {
256-
"type": "string"
257-
},
258264
"port": {
259265
"anyOf": [
260266
{
@@ -419,8 +425,6 @@
419425
"allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)",
420426
"before": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverbefore)",
421427
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
422-
"ca": "should be {String|Buffer}",
423-
"cert": "should be {String|Buffer}",
424428
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'silent', 'info', 'debug', 'trace', 'error', 'warning', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
425429
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
426430
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
@@ -436,7 +440,6 @@
436440
"index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverindex)",
437441
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
438442
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
439-
"key": "should be {String|Buffer}",
440443
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload-)",
441444
"log": "should be {Function}",
442445
"logLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://github.com/webpack/webpack-dev-middleware#loglevel)",
@@ -447,8 +450,6 @@
447450
"open": "should be {String|Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveropen)",
448451
"openPage": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devserveropenpage)",
449452
"overlay": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveroverlay)",
450-
"pfx": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserverpfx)",
451-
"pfxPassphrase": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpfxpassphrase)",
452453
"port": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserverport)",
453454
"profile": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprofile)",
454455
"progress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprogress---cli-only)",

lib/utils/createConfig.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,26 +151,6 @@ function createConfig(config, argv, { port }) {
151151
options.http2 = true;
152152
}
153153

154-
if (argv.key) {
155-
options.key = argv.key;
156-
}
157-
158-
if (argv.cert) {
159-
options.cert = argv.cert;
160-
}
161-
162-
if (argv.cacert) {
163-
options.ca = argv.cacert;
164-
}
165-
166-
if (argv.pfx) {
167-
options.pfx = argv.pfx;
168-
}
169-
170-
if (argv.pfxPassphrase) {
171-
options.pfxPassphrase = argv.pfxPassphrase;
172-
}
173-
174154
if (argv.historyApiFallback) {
175155
options.historyApiFallback = true;
176156
}

test/__snapshots__/Validation.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ exports[`Validation validation should fail validation for invalid \`writeToDisk\
3737
exports[`Validation validation should fail validation for no additional properties 1`] = `
3838
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
3939
- configuration has an unknown property 'additional'. These properties are valid:
40-
object { after?, allowedHosts?, before?, bonjour?, ca?, cert?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, key?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, pfx?, pfxPassphrase?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }"
40+
object { after?, allowedHosts?, before?, bonjour?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }"
4141
`;

0 commit comments

Comments
 (0)