miniflare icon indicating copy to clipboard operation
miniflare copied to clipboard

Self-signed certificates

Open TrySound opened this issue 3 years ago • 4 comments

I found this project use selfsigned package to generate certificates. I recently played with it in vite and found it does not generate valid certificates. Chrome shows red wall.

Is there a reason to use it considering it has big install size because of node-forge? https://packagephobia.com/result?p=selfsigned

image

TrySound avatar Feb 23 '22 08:02 TrySound

Hey! 👋 Apologies for the delayed response. I think this is expected. Chrome will always warn on self-signed certificates unless you explicitly trust them. If you click Advanced, you should be able to proceed.

I'd love to remove the dependency on node-forge, though I'm not sure Node's built-in crypto module supports everything required to generate these certificates natively. Do you know of any other lightweight packages for generating certificates?

mrbbot avatar Mar 04 '22 20:03 mrbbot

It doesn't. I tried to provide an alternative in vite but crypto is not enough here to generate actual certificate, only keys. We decided to remove this dep from vite in favour of either a plugin or a recipe with selfsigned which is simply passed to the config module.

Btw my teammate, @istarkov, figured a way to use cloudflare for https. https://dev.to/istarkov/fast-and-easy-way-to-setup-web-developer-certificates-450e

TrySound avatar Mar 04 '22 20:03 TrySound

Also see here since vite bundles most of its dependencies we were able to reduce it's size in v2 (will be removed in v3) by pickings parts of its code. Perhaps doesn't make sense in this project. https://github.com/vitejs/vite/blob/main/packages/vite/src/node/certificate.ts#L36-L39

TrySound avatar Mar 04 '22 20:03 TrySound

Ah ok, thanks for those details. Vite's v2 implementation looks interesting. We're already bundling some of our dependencies so should be able to integrate that. 👍

Will consider removing this feature in the next major version too...

mrbbot avatar Mar 04 '22 21:03 mrbbot