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

chore: use forge partially to generate certificates #6325

Merged
merged 1 commit into from Dec 30, 2021

Conversation

TrySound
Copy link
Contributor

Description

watching The Matrix while hacking these certificates

Alternative to #6173

Since sharing same certificate for all users is not the best approach
I suggest to try decompose node-forge which is used internally by
selfsigned package. We can just use part of the package which already
gives a good result.

Eventually we will deprecate this feature but would be good to have less
impact on current major too.

du -sk dist/node

before: 10760
after: 9944

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

> watching The Matrix while hacking these certificates

Alternative to vitejs#6173

Since sharing same certificate for all users is not the best approach
I suggest to try decompose node-forge which is used internally by
selfsigned package. We can just use part of the package which already
gives a good result.

Eventually we will deprecate this feature but would be good to have less
impact on current major too.

```
du -sk dist/node
```
before: 10760
after: 9944
@Niputi Niputi added the p1-chore Doesn't change code behavior (priority) label Dec 30, 2021
@patak-dev patak-dev added this to the 2.8 milestone Dec 30, 2021
@patak-dev
Copy link
Member

LGTM, @dominikg @userquin @aleclarson what do you think?

}

export function createCertificate(): string {
const days = 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more days, the limit is too short, I configure the ssl/tls certificates with 2 years

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we have with existing logic. I think it's ok to keep as is if we are gonna deprecate and remove this feature eventually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TrySound can you provide a certificate generated with the code here?, my email is userquin@gmail.com

const attrs = [
{
name: 'commonName',
value: 'example.org'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CN should match the subject alternative name, browser will complain

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do another PR afterwards to improve these things? Lets review only the change away from selfsigned in this one and you can send the next one on top of it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is selfsigned default. Do we need to change anything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, just remove the CN, should work, here an example with the certificate generated with https-localhost:

imagen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is selfsigned default. Do we need to change anything?

I know this will be deprecated but if included add something functional, 30 days is too short, and from the logic perspective the work to be done to include 2 years doesn't matter (we are not changing the key lengths from 2048 to 4096 bits). The SSL/TLS certificates on browsers are quite sensitive...

Copy link
Member

@patak-dev patak-dev Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@userquin could you check the PR against the current implementation? I think we have the same values. Lets try to merge this one and I think we can better discuss changes to the params in a future PR (hopefully from you :) )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patak-dev ok, no problem, I'm creating the p12 to import on windows and preparing some test..

@userquin
Copy link
Contributor

I need to review a few things for browser support: I think we need to create the ssl/tls certificate for localhost only...

@patak-dev patak-dev merged commit dd8869b into vitejs:main Dec 30, 2021
@Niputi Niputi mentioned this pull request Dec 31, 2021
9 tasks
@userquin
Copy link
Contributor

userquin commented Dec 31, 2021

@patak-dev @TrySound working (screenshots on windows + Edge, also working on windows + Chrome), adding the public cert to the trusted ca certificates on windows

imagen

imagen

@patak-dev
Copy link
Member

This is great @userquin, so no further changes are required?

@TrySound TrySound deleted the decompose-forge branch December 31, 2021 10:10
@userquin
Copy link
Contributor

This is great @userquin, so no further changes are required?

Yes, no changes required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants