Skip to content

Commit b212a2c

Browse files
authored
feat: add https.cacert (#3240)
BREAKING CHANGE: `https.ca` was removed in favor `https.cacert`
1 parent 6e0e653 commit b212a2c

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class Server {
504504
}
505505

506506
if (this.options.https) {
507-
for (const property of ['ca', 'pfx', 'key', 'cert']) {
507+
for (const property of ['cacert', 'pfx', 'key', 'cert']) {
508508
const value = this.options.https[property];
509509
const isBuffer = value instanceof Buffer;
510510

lib/options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
"requestCert": {
313313
"type": "boolean"
314314
},
315-
"ca": {
315+
"cacert": {
316316
"anyOf": [
317317
{
318318
"type": "string"

test/__snapshots__/validate-options.test.js.snap.webpack4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,18 @@ exports[`options validate should throw an error on the "http2" option with '' va
178178
exports[`options validate should throw an error on the "https" option with '' value 1`] = `
179179
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
180180
- configuration.https should be one of these:
181-
boolean | object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }
181+
boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }
182182
-> By default, dev-server will be served over HTTP. It can optionally be served over HTTP/2 with HTTPS. https://webpack.js.org/configuration/dev-server/#devserverhttps
183183
Details:
184184
* configuration.https should be a boolean.
185185
* configuration.https should be an object:
186-
object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }"
186+
object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }"
187187
`;
188188

189189
exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = `
190190
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
191191
- configuration.https has an unknown property 'foo'. These properties are valid:
192-
object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }"
192+
object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }"
193193
`;
194194

195195
exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = `

test/__snapshots__/validate-options.test.js.snap.webpack5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,18 @@ exports[`options validate should throw an error on the "http2" option with '' va
178178
exports[`options validate should throw an error on the "https" option with '' value 1`] = `
179179
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
180180
- configuration.https should be one of these:
181-
boolean | object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }
181+
boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }
182182
-> By default, dev-server will be served over HTTP. It can optionally be served over HTTP/2 with HTTPS. https://webpack.js.org/configuration/dev-server/#devserverhttps
183183
Details:
184184
* configuration.https should be a boolean.
185185
* configuration.https should be an object:
186-
object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }"
186+
object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }"
187187
`;
188188

189189
exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = `
190190
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
191191
- configuration.https has an unknown property 'foo'. These properties are valid:
192-
object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }"
192+
object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }"
193193
`;
194194

195195
exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = `

test/server/https-option.test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('https option', () => {
4545
afterAll(testServer.close);
4646
});
4747

48-
describe('as an object when ca, pfx, key and cert are buffer', () => {
48+
describe('as an object when cacert, pfx, key and cert are buffer', () => {
4949
beforeAll((done) => {
5050
server = testServer.start(
5151
config,
@@ -55,7 +55,9 @@ describe('https option', () => {
5555
watch: false,
5656
},
5757
https: {
58-
ca: fs.readFileSync(path.join(httpsCertificateDirectory, 'ca.pem')),
58+
cacert: fs.readFileSync(
59+
path.join(httpsCertificateDirectory, 'ca.pem')
60+
),
5961
pfx: fs.readFileSync(
6062
path.join(httpsCertificateDirectory, 'server.pfx')
6163
),
@@ -79,14 +81,14 @@ describe('https option', () => {
7981
});
8082
});
8183

82-
describe('as an object when ca, pfx, key and cert are paths', () => {
84+
describe('as an object when cacert, pfx, key and cert are paths', () => {
8385
beforeAll((done) => {
8486
server = testServer.start(
8587
config,
8688
{
8789
static: contentBasePublic,
8890
https: {
89-
ca: path.join(httpsCertificateDirectory, 'ca.pem'),
91+
cacert: path.join(httpsCertificateDirectory, 'ca.pem'),
9092
pfx: path.join(httpsCertificateDirectory, 'server.pfx'),
9193
key: path.join(httpsCertificateDirectory, 'server.key'),
9294
cert: path.join(httpsCertificateDirectory, 'server.crt'),
@@ -104,7 +106,7 @@ describe('https option', () => {
104106
});
105107
});
106108

107-
describe('as an object when ca, pfx, key and cert are symlinks', () => {
109+
describe('as an object when cacert, pfx, key and cert are symlinks', () => {
108110
if (skipTestOnWindows('Symlinks are not supported on Windows')) {
109111
return;
110112
}
@@ -118,7 +120,7 @@ describe('https option', () => {
118120
watch: false,
119121
},
120122
https: {
121-
ca: path.join(httpsCertificateDirectory, 'ca-symlink.pem'),
123+
cacert: path.join(httpsCertificateDirectory, 'ca-symlink.pem'),
122124
pfx: path.join(httpsCertificateDirectory, 'server-symlink.pfx'),
123125
key: path.join(httpsCertificateDirectory, 'server-symlink.key'),
124126
cert: path.join(httpsCertificateDirectory, 'server-symlink.crt'),
@@ -138,7 +140,7 @@ describe('https option', () => {
138140
afterAll(testServer.close);
139141
});
140142

141-
describe('as an object when ca, pfx, key and cert are raw strings', () => {
143+
describe('as an object when cacert, pfx, key and cert are raw strings', () => {
142144
beforeAll((done) => {
143145
server = testServer.start(
144146
config,
@@ -148,7 +150,7 @@ describe('https option', () => {
148150
watch: false,
149151
},
150152
https: {
151-
ca: fs
153+
cacert: fs
152154
.readFileSync(path.join(httpsCertificateDirectory, 'ca.pem'))
153155
.toString(),
154156
// pfx can't be string because it is binary format
@@ -186,7 +188,9 @@ describe('https option', () => {
186188
},
187189
https: {
188190
requestCert: true,
189-
ca: fs.readFileSync(path.join(httpsCertificateDirectory, 'ca.pem')),
191+
cacert: fs.readFileSync(
192+
path.join(httpsCertificateDirectory, 'ca.pem')
193+
),
190194
pfx: fs.readFileSync(
191195
path.join(httpsCertificateDirectory, 'server.pfx')
192196
),

test/validate-options.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ const tests = {
180180
false,
181181
true,
182182
{
183-
ca: join(httpsCertificateDirectory, 'ca.pem'),
183+
cacert: join(httpsCertificateDirectory, 'ca.pem'),
184184
key: join(httpsCertificateDirectory, 'server.key'),
185185
pfx: join(httpsCertificateDirectory, 'server.pfx'),
186186
cert: join(httpsCertificateDirectory, 'server.crt'),
187187
requestCert: true,
188188
passphrase: 'webpack-dev-server',
189189
},
190190
{
191-
ca: readFileSync(join(httpsCertificateDirectory, 'ca.pem')),
191+
cacert: readFileSync(join(httpsCertificateDirectory, 'ca.pem')),
192192
pfx: readFileSync(join(httpsCertificateDirectory, 'server.pfx')),
193193
key: readFileSync(join(httpsCertificateDirectory, 'server.key')),
194194
cert: readFileSync(join(httpsCertificateDirectory, 'server.crt')),

0 commit comments

Comments
 (0)