Laravel Valet associating incorrect certificate with secure link
Asked Answered
V

2

5

I've been using Laravel Valet for while, and I've just encountered a situation that is working my last nerve: after creating a new Laravel project, I went to the public directory and did valet link my_project, then valet secure my_project. Now, valet links shows https://my_project.test but when going there, I get "Your connection is not private".

In Chrome, you can click on "Not Secure" and see the certificate, and when I do this, it shows the certificate for a different one of my projects! I have looked at my ~/.config/valet/Certificates directory, and the my_project.test files are all there (.conf, .crt, .csr, and .key). Any helpful suggestions would be most welcome.

Volition answered 10/1, 2021 at 18:57 Comment(3)
I ran into this exact issue yesterday after years without issue. I resolved it with an update of laravel valet and a restart of the service, followed by re-securing the site.Bronnie
@Rory: Wow! That absolutely worked! Thank you!Volition
Me also, looking through the git commit notes I can't identify the cause, but upgrading from Valet 2.11.0 (June 2020) to 2.13.16 (December) was enough to fix.Verde
V
10

Okay—thanks to @Rory, the problem is solved! Here are the steps:

  1. Run composer global update.
  2. Run valet restart.
  3. Do valet unsecure my_project, then valet unlink my_project.
  4. Do valet link my_project, then valet secure my_project

...and Bob's your uncle!

Volition answered 11/1, 2021 at 14:15 Comment(3)
It also helped me after I migrated from one macbook to another using Apple migration assistant. Chrome wouldn't accept Valet ssl so I had to unlink and secure them againPorpoise
Turns out, Bob is not my uncle :(Idelson
I guess I have an uncle named Bob! Thanks a lot.Almatadema
M
1

The answer above is correct, but if you are like me and use Firefox, you can get frustrated. The reason for this on Firefox is that this browser manages its certificates on its own, and not using the root certificates from your current computer. Because of this, you are required to import your Valet Root Certificate to the browser to allow this to open Valet website as secure.

Before fixing your browser, is important to know where your Valet setup stores the new CA Certificate:

~/.config/valet/CA/LaravelValetCASelfSigned.pem

I recommend you copy this file on your desktop to find it easily.

To fix your browser and make it work again with Valet you need to:

  • Open Firefox (Yes, I always assume the browser is closed).
  • Go to Settings (Triple bar icon on the right top corner) or CMD+,.
  • Click on Privacy and Security.
  • Scroll Down until you find Security > Certificates. Click on View Certificates....
  • On the new screen, Click on Authorities.
  • Scroll until the end of the screen (Be sure to scroll, because it looks like there's a nested scroll on that screen) until you find the Import... option.
  • Look for the LaravelValetCASelfSigned.pem file and click Open.
  • Click Ok and close and reopen your Browser.

Now your Firefox browser should work as expected.

Myogenic answered 22/12, 2022 at 18:16 Comment(3)
Here's another great resource about this topic: javorszky.co.uk/2019/11/06/…Myogenic
More details about this issue: github.com/laravel/valet/issues/296Myogenic
Ricardo, you rock. Thanks a lot!!!Theatrical

© 2022 - 2024 — McMap. All rights reserved.