Gatsby: --https fails if the path of the project contains spaces

Created on 30 Jul 2019  路  11Comments  路  Source: gatsbyjs/gatsby

Description

command gatsby run develop --https fails in the generate certificate step if the path of the project contains spaces

Steps to reproduce

I'm on windows, so I don't know if the same steps will reproduce the issue on other OS's

  1. Create a user whose name contains spaces
  2. Create a project anywhere
  3. Install openssl and add it to the PATH env variable
  4. run the command gatsby develop --https

Expected result

Gatsby generates certificate and starts an https server

Actual result

Error
Error: Command failed: openssl genrsa -out C:\Users\User Name With Spaces\AppData\Local\devcert\config\devcert-ca-root.key 2048
and process exits

Environment

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
Binaries:
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.15
Browsers:
Edge: 42.17134.1.0
npmPackages:
gatsby: ^2.13.3 => 2.13.3
gatsby-image: ^2.2.4 => 2.2.4
gatsby-plugin-intl: ^0.2.6 => 0.2.6
gatsby-plugin-manifest: ^2.2.1 => 2.2.1
gatsby-plugin-offline: ^2.2.0 => 2.2.0
gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0
gatsby-plugin-sharp: ^2.2.2 => 2.2.2
gatsby-source-filesystem: ^2.1.2 => 2.1.2
gatsby-transformer-sharp: ^2.2.1 => 2.2.1

good first issue help wanted stale? bug

Most helpful comment

I'm currently tackling this issue! I'm running some tests and should have a PR this weekend.

All 11 comments

Hello!

Thank you for reporting this! I suspect that the generated certificate isn't escaped. It shouldn't be a very big fix. Would you like to make a PR fixing that? We would greatly appreciate that.

Thank you! :purple_heart: :muscle:

@freiksenet I would love to contribute by fixing this. Let's discuss how to achieve this.

The issue here is in the npm package devcerts-san, called from here:

https://github.com/gatsbyjs/gatsby/blob/c1960a260d3fbd5b6f57fb29317693d45a0686d3/packages/gatsby/src/utils/get-ssl-cert.js

That particular error is generated here:

https://github.com/davewasmer/devcert/blob/v0.3.2/src/utils.ts#L36

But this whole function will have trouble:

https://github.com/davewasmer/devcert/blob/v0.3.2/src/index.ts#L81-L88

That utility is calling openssl from the shell, and unquoted/unescaped strings are being dropped into the command.

There is version 1.0.0, though. It is now called devcert (instead of devcert-san), and after a quick look at these few lines, it looks like the bug has been fixed:

https://github.com/davewasmer/devcert/blob/master/src/certificates.ts#L28
https://github.com/davewasmer/devcert/blob/master/src/certificates.ts#L36
https://github.com/davewasmer/devcert/blob/master/src/certificates.ts#L44

Upgrading the package should work, but it wouldn't be just a simple version upgrade, since there were breaking changes. A few things that would effect Gatsby.

https://github.com/davewasmer/devcert/blob/v0.3.2/src/index.ts#L71-L76
vs
https://github.com/davewasmer/devcert/blob/master/src/index.ts#L71-L74

(Node's https.createServer() (called here to setup the server) does not require the key/cert paths. Which is probably why they are no longer returned by devcert.)

Options are listed here:
https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options

I'm currently tackling this issue! I'm running some tests and should have a PR this weekend.

Hey, made a PR above! I'm running Linux, so I can't confirm if the fix runs on Windows. Can someone on Windows run my fork and see if this issue still fails? Thank you!

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Still in progress

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

PR fixing this issue is ready to be reviewed/merged.

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 馃挭馃挏

Was this page helpful?
0 / 5 - 0 ratings