mirror of
https://github.com/FiloSottile/mkcert.git
synced 2026-04-25 05:26:03 +03:00
[GH-ISSUE #357] What is the process for installing in WSL2? #234
Labels
No labels
TLS stack issue
Windows
bug
duplicate
duplicate
enhancement
help wanted
help wanted
pull-request
question
question
root store
waiting for info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mkcert#234
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cheslijones on GitHub (Mar 20, 2021).
Original GitHub issue: https://github.com/FiloSottile/mkcert/issues/357
I honestly can't say if the problem is with WSL2, Docker, Kubernetes, Minikube or mkcert, but I'm wondering: what is the installation process is for WSL2? Should it be done Windows side, or should it be done inside WSL2?
I have the same process for my Linux partition and macOS. The deployment works fine those two but not inside of WSL. The deployment is basically the following:
At the end of this (on macOS and Linux), you should be able to spin-up the application, navigate to
localhostand there is a valid TLS certificate.Doesn't work on WSL2 however and while the error is Kubernetes related:
(
tls-localhost-devvery clearly does exist, btw)...I can't help but think it is an issue with WSL2 and the
mkcertcertificates. WSL2 does some weird stuff with networking to say the least.Should
mkcertnot be used and certificates not installed directly in WSL2? Should they go into Windows itself?@rfay commented on GitHub (Mar 20, 2021):
If you want the windows-side browser to trust something that's in wsl2 you have to do a little bit. I think we have this pretty well dialed in in the instructions for ddev, https://ddev.readthedocs.io/en/latest/#installation-or-upgrade-windows-wsl2
What we do is create the CA on the Windows side and then tell WSL2 to use that one.
@cheslijones commented on GitHub (Mar 21, 2021):
Thanks for the documentation.
Unfortunately, I've been unable to get it
mkcertworking for my use case and still run into the same issues when it comes to deploying the local dev k8s cluster. Likely going to have to chalk this up to another issue unique to WSL2 (given it works fine in Linux and macOS) and move on.I'm pretty sure
mkcertis doing what it needs to do, so I'll check with thecert-managerdevs to see if they might have any ideas.@cheslijones commented on GitHub (Mar 28, 2021):
Ok, got this figured out with some help:
This is what worked for my use case. Granted, I didn't test it without installing
mkcertinto WSL, so that step may not be necessary:chocoto installmkcert:choco install -y mkcertmkcert -installmkcert(again, not 100% sure this is necessary):mkcert -install(again, not 100% sure this is necessary)C:\Users\<user>\directory by defaultkubectl apply -f k8s/dev/tls.yamlwhich contains:This time after running
skaffold dev, andminikube tunnel, my app is running with the TLS certificates like it should be.@ronilaukkarinen commented on GitHub (Apr 12, 2021):
I'd also like to know how to get certs to work with Windows development environment. I installed mkcert like this:
And then got mkcert certificate with:
But in the browser it's not valid cert.
Any tips on how to get the cert green here?
@siruku6 commented on GitHub (Aug 28, 2022):
I got an error by
sudo apt install linuxbrew-wrapper -yon wsl2.But could resolve by following this article.
Environment
I'm using ubuntu20.04.
Error
Resolution
And I recommend to set
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"in.bashrc.@ledunguit commented on GitHub (Mar 13, 2023):
For anyone who facing this issue, the steps to use mkcert in the WSL2 to be trusted by window side:
mkcert -installfrom WSL2/usr/local/share/ca-certificatesto any directory on Windows, for example I will copy to theD:drive on Windows:cp /usr/local/share/ca-certificates/mkcert_development_CA_257563636493456315191321627148517461377.crt /mnt/d/D:\mkcert_development_CA_257563636493456315191321627148517461377.crt. Install it toTrusted Root Certification AuthoritiesWindows + Rand pastecertmgr.mscand verify it from the list like in the bottom image@AlexErrant commented on GitHub (Mar 16, 2023):
@ledunguit's advice worked for me. You may skip the
cpstep by opening e.g.\\wsl$\Ubuntu-20.04\usr\local\share\ca-certificatesinexplorer.exeand double-clicking the cert there.And to be explicit, on step 4, choose the option
Place all certificates in the following storeand select
Trusted Root Certification Authorities.@shinzoke commented on GitHub (May 29, 2023):
Eugh finally! the 2 comments above me finally created the solution I needed after breaking my head over the certificates I needed for my used case, pretty new to wsl to 😀
@ToshY commented on GitHub (Nov 28, 2023):
@ledunguit @AlexErrant
I'm on Win 11 22h2 and I don't have a default program to open
.pemfile created bymkcert -install. What's the "program" that gives the pop-up with the "Install certificate" button?@ledunguit commented on GitHub (Nov 28, 2023):
@ToshY Can you please take a screenshot what happened when you double click the cert? I am also using Win 11 22H2 too.
@ToshY commented on GitHub (Nov 28, 2023):
Hey @ledunguit 👋
Either way when clicking it in explorer from the WSL path, as well as copying the certificate to my C drive, both give the same result.
I'm not sure, but it seems that doesn't automatically recognizes the
.pemfiles as certificates that can be installed, and therefore doesn't have a default program to "open" the files?@ledunguit commented on GitHub (Nov 28, 2023):
@ToshY Ok, I see. Your certificate is in
PEMformat, notCRT. You can import therootCA.pemusing various methods. One of them is outlined here: https://learn.microsoft.com/en-us/skype-sdk/sdn/articles/installing-the-trusted-root-certificate@ToshY commented on GitHub (Nov 28, 2023):
@ledunguit Thanks for the link!
I'm just curious now how did you perform a
mkcert -installand get a.crtfrom it? I don't really see options/docs that show how to achieve that, and from what I can see from the README it also showsrootCA.pemas default output frommkcert -install. 🤔@AlexErrant commented on GitHub (Nov 28, 2023):
Looks like it depends on some paths existing and therefore maybe what distro you're on:
github.com/FiloSottile/mkcert@2a46726ceb/truststore_linux.go (L36-L48)I'm on Ubuntu-20.04
@ToshY commented on GitHub (Nov 28, 2023):
As
mkcert -CAROOTshows for me/home/user/.local/share/mkcert, which containsrootCA.pemandrootCA-key.pem. This is, according to the docs the certificates you should use for installing on other systems.But now I finally see that both the snippet @AlexErrant shows, as well as the original comment from @ledunguit, show references to
/usr/local/share/ca-certificates/directory, which I also have and contains themkcert_development_CA_<123456>.crt.Now I've done a quick
sha256sumon both the/home/user/.local/share/mkcert/rootCA.pemand/usr/local/share/ca-certificates/mkcert_development_CA_<123456>.crt, and surprise-surprise, it's the same 🤦♂️This is on me for not reading your suggestions better 😞
What I did find, after trying to open the
.crt, is that it uses an application called "Crypto Shell Extensions", but by default it doesn't associate with.pem. So I found this snippet which actually fixes it.add-pem-as-cert.regAfter executing, I can double-click the
.pemfile, and get the same pop-up to install the certificate 😄@marveloo commented on GitHub (Jan 22, 2025):
Installing
mkcertroot certificate into the Windows certificate store can be done by running this in Linux shell:I believe the developers of
mkcertcould integrate this (or a similar) command into themkcert -installprocess. It would be a convenient feature for WSL users 😎.@ToshY commented on GitHub (Jan 22, 2025):
This is awesome ❤ It would be even better if the pop-up security warning can be automatically confirmed, but it still beats following the manual steps. Thanks!
@airtonix commented on GitHub (Mar 20, 2025):
This only works if you've not optimised the speed of your WSL2 instance by disabling the ability to run windows commands from within wsl2.
My concession is to do the following :