Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack5: devserver does not work with --cacert CLI option #2996

Closed
1 of 2 tasks
rytnkmr opened this issue Feb 6, 2021 · 7 comments · Fixed by #3241
Closed
1 of 2 tasks

webpack5: devserver does not work with --cacert CLI option #2996

rytnkmr opened this issue Feb 6, 2021 · 7 comments · Fixed by #3241

Comments

@rytnkmr
Copy link

rytnkmr commented Feb 6, 2021

  • Operating System: macOS Catalina 10.15.7
  • Node Version: 10.15.7
  • NPM Version: 7.5.2
  • webpack Version: 5.21.1
  • webpack-dev-server Version: 3.11.2
  • Browser: -
  • This is a bug
  • This is a modification request

Code

// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  mode: 'development',
  plugins: [new webpack.ProgressPlugin(), new HtmlWebpackPlugin({
            template: 'index.html'
          })],
  module: {
    rules: []
  },
  devServer: {
    open: true,
    host: 'localhost'
  }
}

Expected Behavior

dev-server is served and cacert.pem is used

Actual Behavior

image

log is below:

0 verbose cli [
0 verbose cli   '/Users/rytnkmr/.nodebrew/node/v14.15.4/bin/node',
0 verbose cli   '/Users/rytnkmr/.nodebrew/node/v14.15.4/lib/node_modules/npm/bin/npm-cli.js',
0 verbose cli   'exec',
0 verbose cli   '--',
0 verbose cli   'webpack',
0 verbose cli   'serve',
0 verbose cli   '--https',
0 verbose cli   '--cert',
0 verbose cli   'localhost.crt',
0 verbose cli   '--key',
0 verbose cli   'localhost.key',
0 verbose cli   '--cacert',
0 verbose cli   'cacert.pem'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 0ms
4 timing config:load:file:/Users/rytnkmr/.nodebrew/node/v14.15.4/lib/node_modules/npm/npmrc Completed in 0ms
5 timing config:load:builtin Completed in 0ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/rytnkmr/dev/experiments/myproject/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/Users/rytnkmr/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/Users/rytnkmr/.nodebrew/node/v14.15.4/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 5ms
19 verbose npm-session b0d13c6ffd6bd81f
20 timing npm:load Completed in 11ms
21 timing command:exec Completed in 806ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (/Users/rytnkmr/.nodebrew/node/v14.15.4/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
22 verbose stack     at ChildProcess.emit (events.js:315:20)
22 verbose stack     at maybeClose (internal/child_process.js:1048:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
23 verbose pkgid [email protected]
24 verbose cwd /Users/rytnkmr/dev/experiments/myproject
25 verbose Darwin 19.6.0
26 verbose argv "/Users/rytnkmr/.nodebrew/node/v14.15.4/bin/node" "/Users/rytnkmr/.nodebrew/node/v14.15.4/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "webpack" "serve" "--https" "--cert" "localhost.crt" "--key" "localhost.key" "--cacert" "cacert.pem"
27 verbose node v14.15.4
28 verbose npm  v7.5.2
29 error code 2
30 error path /Users/rytnkmr/dev/experiments/myproject
31 error command failed
32 error command sh -c webpack "serve" "--https" "--cert" "localhost.crt" "--key" "localhost.key" "--cacert" "cacert.pem"
33 verbose exit 2

I added devServer.ca property in the configuration file and tried without --cacert option, then it works.

// webpack.config.js
  devServer: {
    ca: 'cacert.pem', // add
    open: true,
    host: 'localhost'
  }
npx webpack serve --https --cert localhost.crt --key localhost.key

For Bugs; How can we reproduce the behavior?

start devServer with --cacert option

npx webpack serve --https --cert [path to cert] --key [path to key] --cacert [path to cacert]
@snitin315
Copy link
Member

Are you using the latest version of webpack-cli?

@rytnkmr
Copy link
Author

rytnkmr commented Feb 17, 2021

Are you using the latest version of webpack-cli?

@snitin315
Yes, my webpack-cli is of version 4.5.0

@alexander-akait
Copy link
Member

@rytnkmr can you run webpack serve --help?

@rytnkmr
Copy link
Author

rytnkmr commented Feb 17, 2021

@alexander-akait
sorry, I made a mistake. here is the result of webpack serve --help

Usage: webpack serve|s [entries...] [options]

Run the webpack dev server.

Options:
  -c, --config <value...>     Provide path to a webpack configuration file e.g. ./webpack.config.js.
  --config-name <value...>    Name of the configuration to use.
  -m, --merge                 Merge two or more configurations using 'webpack-merge'.
  --env <value...>            Environment passed to the configuration when it is a function.
  --progress [value]          Print compilation progress during build.
  -j, --json [value]          Prints result as JSON or store it in a file.
  -d, --devtool <value>       Determine source maps to use.
  --no-devtool                Do not generate source maps.
  --entry <value...>          The entry point(s) of your application e.g. ./src/main.js.
  --mode <value>              Defines the mode to pass to webpack.
  --name <value>              Name of the configuration. Used when loading multiple configurations.
  -o, --output-path <value>   Output location of the file generated by webpack e.g. ./dist/.
  --stats [value]             It instructs webpack on how to treat the stats e.g. verbose.
  --no-stats                  Disable stats output.
  -t, --target <value...>     Sets the build target e.g. node.
  --watch-options-stdin       Stop watching when stdin stream has ended.
  --no-watch-options-stdin    Do not stop watching when stdin stream has ended.
  --bonjour                   Broadcasts the server via ZeroConf networking on start
  --lazy                      Lazy
  --liveReload                Enables/Disables live reloading on changing files
  --serveIndex                Enables/Disables serveIndex middleware
  --inline                    Inline mode (set to false to disable including client scripts like livereload)
  --progress                  Print compilation progress in percentage
  --hot-only                  Do not refresh page if HMR fails
  --stdin                     close when stdin ends
  --open [value]              Open the default browser, or optionally specify a browser name
  --useLocalIp                Open default browser with local IP
  --open-page <value>         Open default browser with the specified page
  --client-log-level <value>  Log level in the browser (trace, debug, info, warn, error or silent)
  --https                     HTTPS
  --http2                     HTTP/2, must be used with HTTPS
  --key <value>               Path to a SSL key.
  --cert <value>              Path to a SSL certificate.
  --cacert <value>            Path to a SSL CA certificate.
  --pfx <value>               Path to a SSL pfx file.
  --pfx-passphrase <value>    Passphrase for pfx file.
  --content-base <value>      A directory or URL to serve HTML content from.
  --watch-content-base        Enable live-reloading of the content-base.
  --history-api-fallback      Fallback to /index.html for Single Page Applications.
  --compress                  Enable gzip compression
  --port <value>              The port
  --disable-host-check        Will not check the host
  --socket <value>            Socket to listen
  --public <value>            The public hostname/ip address of the server
  --host <value>              The hostname/ip address the server will bind to
  --allowed-hosts <value...>  A list of hosts that are allowed to access the dev server, separated by spaces

Global options:
  --color                     Enable colors on console.
  --no-color                  Disable colors on console.
  -v, --version               Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and
                              commands.
  -h, --help [verbose]        Display help for commands and options.

To see list of all supported commands and options run 'webpack --help=verbose'.

Webpack documentation: https://webpack.js.org/.
CLI documentation: https://webpack.js.org/api/cli/.
Made with ♥ by the webpack team.

@alexander-akait
Copy link
Member

As you can see no the cacert option

@rytnkmr
Copy link
Author

rytnkmr commented Feb 17, 2021

@alexander-akait
There was missing lines, so I pasted the result again in the previous comment.
There is the --cacert option.

@alexander-akait
Copy link
Member

I will look at this in near future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants