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

--https fails if the path of the project contains spaces #16212

Closed
salmaDariwsh opened this issue Jul 30, 2019 · 11 comments · Fixed by #16726 or #18703
Closed

--https fails if the path of the project contains spaces #16212

salmaDariwsh opened this issue Jul 30, 2019 · 11 comments · Fixed by #16726 or #18703
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@salmaDariwsh
Copy link

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

@freiksenet
Copy link
Contributor

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! 💜 💪

@freiksenet freiksenet added good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby labels Aug 7, 2019
@sagarnasit
Copy link
Contributor

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

@Js-Brecht
Copy link
Contributor

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

@rmorabia
Copy link
Contributor

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

@rmorabia
Copy link
Contributor

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!

@gatsbot
Copy link

gatsbot bot commented Sep 10, 2019

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’s 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! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Sep 10, 2019
@Js-Brecht Js-Brecht added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Sep 11, 2019
@Js-Brecht
Copy link
Contributor

Still in progress

@github-actions
Copy link

github-actions bot commented Dec 3, 2019

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’s 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! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 3, 2019
@Js-Brecht
Copy link
Contributor

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

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 4, 2019
@github-actions
Copy link

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’s 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! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 24, 2019
@github-actions
Copy link

github-actions bot commented Jan 3, 2020

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m 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! 💪💜

@github-actions github-actions bot closed this as completed Jan 3, 2020
wardpeet added a commit that referenced this issue Feb 29, 2020
I changed devcert-san to devcert as described by @Js-Brecht in this comment: #16212 (comment)

This should work, however, I'm running on Linux (unix line endings?) and can't confirm it. Can someone on Windows run the repo before the PR is merged and confirm it's fixed?

Co-authored-by: Ward Peeters <ward@coding-tech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
7 participants