Webpack-dev-server: Problem with custom ssl certificate

Created on 4 May 2017  路  4Comments  路  Source: webpack/webpack-dev-server

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Create certificate:

if [ ! -f server.pem -o ! -f server.key ]; then
  openssl req -newkey rsa:2048 -x509 -keyout server.key -out server.pem -days 365 -nodes -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost"
  chmod 400 server.pem
fi                                                                       

Provide options:

                        https: true,
                        cert: '/ssl/server.pem',
                        key: '/ssl/server.key',

See error:

-node_1   | [09:43:56] Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
-node_1   |     at Error (native)
-node_1   |     at Object.createSecureContext (_tls_common.js:67:17)
-node_1   |     at Server (_tls_wrap.js:754:25)
-node_1   |     at Server (https.js:17:14)
-node_1   |     at Server._init (/src/node_modules/spdy/lib/spdy/server.js:57:10)

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention your webpack and Operating System version.

webpack-dev-server@^2.3.0:
    spdy "^3.4.1"

Most helpful comment

Yeap, it worked.

cert: fs.readFileSync('/ssl/server.pem'),
key: fs.readFileSync('/ssl/server.key'),

All 4 comments

This SO suggests there's something with text vs binary format:

http://stackoverflow.com/questions/31630544/cant-get-private-key-with-openssl-no-start-linepem-lib-c703expecting-any-p

Which key format does the server expect? Can it detect the format itself? Because nginx does fine.

Oh, maybe I should provide contents instead of path?

Yeap, it worked.

cert: fs.readFileSync('/ssl/server.pem'),
key: fs.readFileSync('/ssl/server.key'),

BTW #651 looks similar. Maybe more examples should be added to docs...

Was this page helpful?
0 / 5 - 0 ratings