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

crash when running http-server --ssl #135

Closed
jantimon opened this issue Mar 4, 2015 · 4 comments · Fixed by #479
Closed

crash when running http-server --ssl #135

jantimon opened this issue Mar 4, 2015 · 4 comments · Fixed by #479

Comments

@jantimon
Copy link
Contributor

jantimon commented Mar 4, 2015

http-server -S

fs.js:427
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'key.pem'
    at Object.fs.openSync (fs.js:427:18)
    at Object.fs.readFileSync (fs.js:284:15)
    at Object.core.createServer (/usr/local/lib/node_modules/http-server/node_modules/union/lib/core.js:73:16)
    at new exports.HTTPServer (/usr/local/lib/node_modules/http-server/lib/http-server.js:72:23)
    at Object.exports.createServer (/usr/local/lib/node_modules/http-server/lib/http-server.js:84:10)
    at listen (/usr/local/lib/node_modules/http-server/bin/http-server:86:27)
    at options.root (/usr/local/lib/node_modules/http-server/bin/http-server:55:5)
    at Server.onListen (/usr/local/lib/node_modules/http-server/node_modules/portfinder/lib/portfinder.js:48:5)
    at Server.g (events.js:180:16)
    at Server.EventEmitter.emit (events.js:92:17)

It would be cool if you provided a default certificate file.

@anjunatl
Copy link

➜  node_modules/http-server/bin/http-server dist/ -a 0.0.0.0 -p 8000 -c-1 --cors --ssl

fs.js:584
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'key.pem'
    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at Object.core.createServer (/Users/kehoff/Development/vmrapiddeploy/vmRapidUI/node_modules/union/lib/core.js:73:16)
    at new HttpServer (/Users/kehoff/Development/vmrapiddeploy/vmRapidUI/node_modules/http-server/lib/http-server.js:125:23)
    at Object.exports.createServer (/Users/kehoff/Development/vmrapiddeploy/vmRapidUI/node_modules/http-server/lib/http-server.js:20:10)
    at listen (/Users/kehoff/Development/vmrapiddeploy/vmRapidUI/node_modules/http-server/bin/http-server:113:27)
    at Object.<anonymous> (/Users/kehoff/Development/vmrapiddeploy/vmRapidUI/node_modules/http-server/bin/http-server:87:3)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

I am seeing it too, using http-server 0.8.5 . It's expecting a key.pem but none is supplied by default. I guess the --ssl option requires the --cert and --key options? It makes sense but the documentation doesn't point that out. Or was a demo cert/key pair supposed uploaded to the repo but wasn't?

I guess this relates to #147.

@metasean
Copy link

metasean commented Aug 4, 2017

I'm seeing he same thing running http-server 0.10.0

$ http-server -p -S
fs.js:652
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'key.pem'
    at Object.fs.openSync (fs.js:652:18)
    at Object.fs.readFileSync (fs.js:553:33)
    at Object.core.createServer (/Users/metasean/site/node_modules/union/lib/core.js:73:16)
    at new HttpServer (/Users/metasean/site/node_modules/http-server/lib/http-server.js:132:23)
    at Object.exports.createServer (/Users/metasean/site/node_modules/http-server/lib/http-server.js:20:10)
    at listen (/Users/metasean/site/node_modules/http-server/bin/http-server:121:27)
    at Object.<anonymous> (/Users/metasean/site/node_modules/http-server/bin/http-server:91:3)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)

    at Module.load (module.js:503:32)

@thornjad
Copy link
Member

thornjad commented Feb 4, 2019

I think there are two issues here. First is that http-server crashes when no cert files are found. I believe this is an issue in union, and so could be solved by #483. As a stop-gap we could check for the existence of those files before giving them to union, and give a friendly error before exiting.

The other issue is generating SSL/TLS certificates on the fly, which may be out of scope for this project.

@offroadkev
Copy link

Even when you specify a cert, it fails. I'm running http-server dist/ -S -C ~/ssl/key.pem -o for a cert I just created and set to 'trusted' specifically for this purpose. I still get..

Error: ENOENT: no such file or directory, open 'key.pem'

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

Successfully merging a pull request may close this issue.

6 participants