diff --git a/lib/Server.js b/lib/Server.js index 7ef6706ea7..870e8c65ea 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -504,7 +504,7 @@ class Server { } if (this.options.https) { - for (const property of ['ca', 'pfx', 'key', 'cert']) { + for (const property of ['cacert', 'pfx', 'key', 'cert']) { const value = this.options.https[property]; const isBuffer = value instanceof Buffer; diff --git a/lib/options.json b/lib/options.json index 461462fad3..bc0b3ae5fe 100644 --- a/lib/options.json +++ b/lib/options.json @@ -309,7 +309,7 @@ "requestCert": { "type": "boolean" }, - "ca": { + "cacert": { "anyOf": [ { "type": "string" diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 3e050e0408..ee5bfc7c7a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -178,18 +178,18 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" option with '' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } -> 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 Details: * configuration.https should be a boolean. * configuration.https should be an object: - object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 3e050e0408..ee5bfc7c7a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -178,18 +178,18 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" option with '' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } -> 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 Details: * configuration.https should be a boolean. * configuration.https should be an object: - object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, ca?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` diff --git a/test/server/https-option.test.js b/test/server/https-option.test.js index 0e206ccd62..887aaba191 100644 --- a/test/server/https-option.test.js +++ b/test/server/https-option.test.js @@ -45,7 +45,7 @@ describe('https option', () => { afterAll(testServer.close); }); - describe('as an object when ca, pfx, key and cert are buffer', () => { + describe('as an object when cacert, pfx, key and cert are buffer', () => { beforeAll((done) => { server = testServer.start( config, @@ -55,7 +55,9 @@ describe('https option', () => { watch: false, }, https: { - ca: fs.readFileSync(path.join(httpsCertificateDirectory, 'ca.pem')), + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, 'ca.pem') + ), pfx: fs.readFileSync( path.join(httpsCertificateDirectory, 'server.pfx') ), @@ -79,14 +81,14 @@ describe('https option', () => { }); }); - describe('as an object when ca, pfx, key and cert are paths', () => { + describe('as an object when cacert, pfx, key and cert are paths', () => { beforeAll((done) => { server = testServer.start( config, { static: contentBasePublic, https: { - ca: path.join(httpsCertificateDirectory, 'ca.pem'), + cacert: path.join(httpsCertificateDirectory, 'ca.pem'), pfx: path.join(httpsCertificateDirectory, 'server.pfx'), key: path.join(httpsCertificateDirectory, 'server.key'), cert: path.join(httpsCertificateDirectory, 'server.crt'), @@ -104,7 +106,7 @@ describe('https option', () => { }); }); - describe('as an object when ca, pfx, key and cert are symlinks', () => { + describe('as an object when cacert, pfx, key and cert are symlinks', () => { if (skipTestOnWindows('Symlinks are not supported on Windows')) { return; } @@ -118,7 +120,7 @@ describe('https option', () => { watch: false, }, https: { - ca: path.join(httpsCertificateDirectory, 'ca-symlink.pem'), + cacert: path.join(httpsCertificateDirectory, 'ca-symlink.pem'), pfx: path.join(httpsCertificateDirectory, 'server-symlink.pfx'), key: path.join(httpsCertificateDirectory, 'server-symlink.key'), cert: path.join(httpsCertificateDirectory, 'server-symlink.crt'), @@ -138,7 +140,7 @@ describe('https option', () => { afterAll(testServer.close); }); - describe('as an object when ca, pfx, key and cert are raw strings', () => { + describe('as an object when cacert, pfx, key and cert are raw strings', () => { beforeAll((done) => { server = testServer.start( config, @@ -148,7 +150,7 @@ describe('https option', () => { watch: false, }, https: { - ca: fs + cacert: fs .readFileSync(path.join(httpsCertificateDirectory, 'ca.pem')) .toString(), // pfx can't be string because it is binary format @@ -186,7 +188,9 @@ describe('https option', () => { }, https: { requestCert: true, - ca: fs.readFileSync(path.join(httpsCertificateDirectory, 'ca.pem')), + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, 'ca.pem') + ), pfx: fs.readFileSync( path.join(httpsCertificateDirectory, 'server.pfx') ), diff --git a/test/validate-options.test.js b/test/validate-options.test.js index eaabf2c05f..ee867d3968 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -180,7 +180,7 @@ const tests = { false, true, { - ca: join(httpsCertificateDirectory, 'ca.pem'), + cacert: join(httpsCertificateDirectory, 'ca.pem'), key: join(httpsCertificateDirectory, 'server.key'), pfx: join(httpsCertificateDirectory, 'server.pfx'), cert: join(httpsCertificateDirectory, 'server.crt'), @@ -188,7 +188,7 @@ const tests = { passphrase: 'webpack-dev-server', }, { - ca: readFileSync(join(httpsCertificateDirectory, 'ca.pem')), + cacert: readFileSync(join(httpsCertificateDirectory, 'ca.pem')), pfx: readFileSync(join(httpsCertificateDirectory, 'server.pfx')), key: readFileSync(join(httpsCertificateDirectory, 'server.key')), cert: readFileSync(join(httpsCertificateDirectory, 'server.crt')),