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

localhost is not a valid domain name #56

Closed
stramel opened this issue Jun 10, 2020 · 16 comments · Fixed by #57
Closed

localhost is not a valid domain name #56

stramel opened this issue Jun 10, 2020 · 16 comments · Fixed by #57

Comments

@stramel
Copy link
Contributor

stramel commented Jun 10, 2020

On the latest version (using devcert-cli):

devcert generate localhost
Error: "localhost" is not a valid domain name.

same for 127.0.0.1 and my local ip

@Js-Brecht
Copy link
Contributor

v1.1.1?

@stramel
Copy link
Contributor Author

stramel commented Jun 10, 2020

@Js-Brecht I believe so, I did a fresh install on my mac using npm I -g devcert-cli and it didn't work. Used the previously installed version on my Windows machine and it worked.

I checked the Regex in the diff for 1.1.1 and it doesn't match for any of the ones I tried.

@Js-Brecht
Copy link
Contributor

What package manager are you using? You should be able to use it to query your dependency tree. Something like yarn why devcert, npm ls devcert, or pnpm ls --filter devcert.

I’m just trying to figure out what version you’re on because an update was published today that would probably cause the problem you’re experiencing

@Js-Brecht
Copy link
Contributor

Oh, I see now you’re using npm. I overlooked that before

@stramel
Copy link
Contributor Author

stramel commented Jun 10, 2020

@Js-Brecht

image

I believe the regex in this latest release is preventing the domains that I'm attempting to use.

@leeuwd
Copy link

leeuwd commented Jun 12, 2020

Same here

image

Gatsby breaks too: https://www.gatsbyjs.org/docs/local-https/

@Js-Brecht
Copy link
Contributor

The RegExp is here:

export const VALID_DOMAIN = /(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/;

I've been really swamped lately, so I don't know when I'll have time to work on that regular expression. It should support IP addresses & single DC (e.g. localhost), but it should also still restrict the domain to valid inputs.

@JustFly1984
Copy link

JustFly1984 commented Jun 19, 2020

In Gatsby.js, pinning devcert to 1.1.0 fixes issues on MaxOS, but causes issues with ubuntu 18 in Github Actions. Errors are the same for both versions: 1.1.0 and 1.1.1

Screenshot 2020-06-19 16 49 57

$ yarn develop
$ gatsby develop -S
info setting up automatic SSL certificate (may require elevated permissions/sudo)

rm: cannot remove '/usr/local/share/ca-certificates/devcert.crt': No such file or directory
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/n/nss/libnss3-tools_3.35-2ubuntu2.7_amd64.deb  404  Not Found [IP: 52.165.132.12 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
error Failed to generate dev SSL certificate


  Error: Command failed: sudo apt install libnss3-tools
  WARNING: apt does not have a stable CLI interface. Use with caution in scripts  .
  E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/n/nss/libns  s3-tools_3.35-2ubuntu2.7_amd64.deb  404  Not Found [IP: 52.165.132.12 80]
  E: Unable to fetch some archives, maybe run apt-get update or try with --fix-m  issing?
  
  - utils.js:22 Object.run
    [poolotto-gatsby]/[devcert]/dist/utils.js:22:28

Our e2e cypress testing is setup to use certificates, and all tests failing, so we can't deploy to any of environments, at least it works locally, but how do you explain that to managers?

crosslinking gatsby issue: gatsbyjs/gatsby#25103

@Js-Brecht
Copy link
Contributor

@JustFly1984 I think one way you could fix that is to install libnss prior to running gatsby develop. That way you can tailor it to the environment it is running in.

@Js-Brecht
Copy link
Contributor

@JustFly1984 try adding this to your action, before your gatsby develop command:

- name: Update apt sources
  run: sudo apt-get update
- name: Install libnss3-tools
  run: sudo apt-get install -y libnss3-tools

@JustFly1984
Copy link

@Js-Brecht we have switched ubuntu to macos-latest in Github actions and reverted [email protected] back, so build pipeline is restored.

1.1.1 does not work for macos with 'localhost' issue. Why is it trying to fetch something after yarn/npm install? Shouldn't everything required for module to run be inside the module?

@Js-Brecht
Copy link
Contributor

devcert uses certutil for managing NSS DBs, and that's what comes with libnss3-tools. Firefox uses NSS DBs, and Chrome does on Linux, too. It would be nice to package all of that up, but there are no bindings for libnss. As a result, devcert relies on the host machine having the library installed.

libnss is an open source library developed by Mozilla, so it's available for anybody to write bindings. I've almost done it myself a few times, but I've got so much other work that is higher priority.

@JustFly1984
Copy link

@Js-Brecht is there any fix to 1.1.1?

@Js-Brecht
Copy link
Contributor

#57 will fix it

@Primajin
Copy link

This issue resurfaced for me in 1.2.1 - 1.2.0 worked fine for me.
I can see it has a new dependency is-valid-domain?

@georgeHtmlBurger
Copy link

I also just did a fresh install using this Gatsby starter: https://github.com/gatsbyjs/gatsby-starter-wordpress-blog and first got issues with a self-signed certificate; once I tried to issue a cert through Gatsby I got that error: "Error: "localhost" is not a valid domain name."

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.

6 participants