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

Fix CA certificates #189

Merged
merged 1 commit into from
Aug 4, 2024
Merged

Conversation

throwaway96
Copy link
Member

The node binary contains a built-in set of trusted CA certificates that never gets updated. Therefore, Node.js services are stuck using whatever certs were bundled when that potentially ancient Node version was released.

Newer versions of Node.js (on webOS 5+) support the --use-openssl-ca option, which makes node use /etc/ssl/certs instead of its own bundle—but that doesn't help us on older versions. Indeed, there doesn't seem to be a clean way to fix this globally on Node 0.10.x and 0.12.x. So, I ended up creating a wrapper around fetch() that controls what certificates it trusts.

All PEM certs in <service dir>/certs will be treated as trusted. I have included the Mozilla CA cert bundle from curl, but users can also add additional certs. If people don't think that's useful, I could simplify the code by just loading a single file (which users could still modify). We could also theoretically just embed the certs in a JS file and avoid the "parsing" part altogether, but that would significantly reduce flexibility.

While testing this on webOS 1, I was able to download and install Kodi and apps hosted on GitHub. It could use more testing on other webOS versions. It's not perfect, but I'm tired. And I want to get a release out this year.

@throwaway96 throwaway96 added the bug Something isn't working label Jun 10, 2024
@throwaway96 throwaway96 added this to the 0.6.4 milestone Jun 10, 2024
services/fetch-wrapper.ts Outdated Show resolved Hide resolved
services/load-certs.js Outdated Show resolved Hide resolved
@kitsuned
Copy link
Member

hey, @throwaway96! you and i may come to some agreement. :)

@Presjar
Copy link

Presjar commented Jul 25, 2024

Can we please just get this merged so the homebrew channel actually works again?

This should work on all webOS versions. It loads certificates from the
Mozilla CA cert bundle. Users may add additional certs by placing
PEM-encoded files in the "certs" directory.

The code for loading the certs can be found at:
https://github.com/throwaway96/node-load-cert-dir
@throwaway96
Copy link
Member Author

throwaway96 commented Jul 30, 2024

I think this can be merged once we get a few positive reports from people testing v0.7.0-test2.

Worked fine for me on webOS 6 (o20n).

@kitsuned kitsuned self-requested a review August 4, 2024 21:07
@throwaway96 throwaway96 merged commit c001b65 into webosbrew:main Aug 4, 2024
1 check passed
@fabio-87
Copy link

fabio-87 commented Aug 29, 2024

The v0.7.0-test2 of Homebrew Channel works for my LG SM9000PLA with webOS 4.x and firmware v05.40.45 🥳
Obviously, if after the above I run the Homebrew Channel Safe Updater, this one overwrite the test version of Homebrew Channel (I think because it downloads the official version) and I must manually reinstall the test version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
6 participants