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

feat: localhost SSL support #341

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dimaslanjaka
Copy link

@dimaslanjaka dimaslanjaka commented Oct 8, 2024

check list

  • Add test cases for the changes.
  • Passed the CI test.

Description

fix #340

Add SSL support for localhost. [FEATURE REQUEST] issue

Additional information

image

accessing from custom local domain

image

accessing from https://localhost:4000

image

accessing from local network

image

homepage

image

gallery

image

post asset link

image

How to test

check it https://github.com/dimaslanjaka/hexo-themes

@dimaslanjaka
Copy link
Author

@SukkaW review please

Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

I myself don't like the idea of pre-exists certificate.

vercel/next.js#54016

What about using mkcert of some sort?

@dimaslanjaka
Copy link
Author

I myself don't like the idea of pre-exists certificate.

vercel/next.js#54016

What about using mkcert of some sort?

mkcert same as openssl the function is same (making locally-trusted self-certificate). user can define their own certificate by passing --cert and --key on hexo server cli

@SukkaW SukkaW self-requested a review October 9, 2024 11:21
@uiolee
Copy link
Member

uiolee commented Jan 2, 2025

Agreed, pre-exists certificate may be difficult to trust

@dimaslanjaka
Copy link
Author

Agreed, pre-exists certificate may be difficult to trust

Then, what is the solution? Should auto certificate creation be made?
If there is no localhost or 127.0.0.1 certificate then you cannot use SSL for localhost.

@dimaslanjaka
Copy link
Author

dimaslanjaka commented Jan 3, 2025

Btw, this feature no need user to install the certificate into their computer. This certificate only for NodeJS http server.
This only uses for outgoing http connection to target url which have SSL with strict rule (cannot mixed incoming connection from http like localhost).

So, this feature does not harm its users.
Useful for adsense localhost testing.
Useful for develop Hexo theme with adsense or other ads platform feature (banner, interstitial, video ads).

@SukkaW
Copy link
Member

SukkaW commented Jan 10, 2025

Then, what is the solution? Should auto certificate creation be made?

At least the certificate should be generated per hexo project and on users' computers. We can store the generated certificates under the node_modules/.cache/hexo-server-certificates folder.

You can refer to vercel/next.js#54016 for the implementation. They are utilizing mkcert to generate a certificate on users' computers per the Next.js project. Unlike OpenSSL, mkcert is a single statically linked binary that can run almost anywhere.

So, this feature does not harm its users.

This is just not even remotely a good practice. Let's avoid it.

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 this pull request may close these issues.

[FEATURE REQUEST] SSL localhost support
3 participants