valet-linux: SSL certificate invalid

I am having trouble to get HTTPS working on my site:

WSL UBUNTU PHP 7.2.10-0ubuntu0.18.04.1 Chrome Version 77.0.3865.120 (Official Build) (64-bit) Valet v2.1.10

I also tried FF and Edge with same result.

In Edge I saved the SSL certificate in a file and then tried to import this file to chrome. This gives me a success message, but the certificate is not showing in chrome.

I did secure my site: $ valet secured mysite.test mysite.test is secured.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23

Most upvoted comments

I had the same problem just go into your browser -> certifcate -> authorities -> import LaravelValetCASelfSigned

LaravelValetCASelfSigned is place in your $HOME/.valet/CA

Then if you re on chrome just enable this parameter chrome://flags/#allow-insecure-localhost .

If you re not on chrome you should have a parameter like this to find.

import LaravelValetCASelfSigned

where can i get LaravelValetCASelfSigned?

Then open Chrome and paste this in the search: chrome://settings/security Click on Manage Certificates Goto the Trusted Root Certification Authorities tab Click Import, Next, Browse

Leave this open then run the following in a terminal for WSL

cd ~/.valet/CA
explorer.exe .

Copy the path in the top bar in the explorer and paste into the browse dialog we opened previously (should look something like below): \\wsl.localhost\Ubuntu\home\YOURWSLUSERNAME\.valet\CA

Then select LaravelValetCASelfSigned.pem (You may have to choose Show All in the bottom right

Then click Open, Next, Next, Finish

Close your browser and open it again and you should have all sites served by valet secure

big thanks to @chiptu , for anyone having hard time finding the browser settings

chrome : search for Manage Certificates > authorities > import LaravelValetCASelfSigned ff : search Certificates > view Certificates > authorities > import LaravelValetCASelfSigned

I solved my issue. The problem is cert9.db key4.db pkcs11.txt files owner issue. valet-linux create the files as root:root. so, valet can’t write files.

My solutions

Unsecure mysite

valet unsecure mysite

Remove pki directory

rm -rf ~/.pki

Make pki directory and change permission

mkdir -p $HOME/.pki/nssdb
chmod -R 700 $HOME/.pki

Secure site : then Valet creates cert9.db key4.db pkcs11.txt files.

valet secure mysite

Check the files.

ls -al ~/.pki/nssdb
drwx------ 2 yourname yourname 4096 10월 24 15:09 ./
drwx------ 3 yourname yourname 4096 10월 24 15:09 ../
-rw------- 1 root root 28672 10월 24 15:09 cert9.db
-rw------- 1 root root 28672 10월 24 15:09 key4.db
-rw------- 1 root root 433 10월 24 15:09 pkcs11.txt

Change the files owner

sudo chown -R yourname:yourname $HOME/.pki/nssdb/

Then valet unsecure mysite valet secure mysite

import LaravelValetCASelfSigned

where can i get LaravelValetCASelfSigned?

Then open Chrome and paste this in the search: chrome://settings/security Click on Manage Certificates Goto the Trusted Root Certification Authorities tab Click Import, Next, Browse

Leave this open then run the following in a terminal for WSL

cd ~/.valet/CA
explorer.exe .

Copy the path in the top bar in the explorer and paste into the browse dialog we opened previously (should look something like below): \\wsl.localhost\Ubuntu\home\YOURWSLUSERNAME\.valet\CA

Then select LaravelValetCASelfSigned.pem (You may have to choose Show All in the bottom right

Then click Open, Next, Next, Finish

Close your browser and open it again and you should have all sites served by valet secure

this one work for me, I am using wsl2 ubuntu 22.04