Use SSL on Laravel Homestead
Solution 1
I assume you are using Windows + Vagrant machine with Homestead.
In this case laravel-cashier.local
is your web application.
You need to copy the certificate inside Vagrant, in Nginx to external folder:
$ sudo cp /etc/nginx/ssl/laravel-cashier.local.crt ~/laravel-cashier/laravel-cashier.local.crt
In Windows environment you can install this certificate with double-click and select the next specific storage:
Trusted Root Certification Authorities
Restart your browser. Done.
More info about how to add certificate: https://technet.microsoft.com/en-us/library/cc754841(v=ws.11).aspx#BKMK_addlocal
NOTE: This is valid for specific browser: Google Chrome
Solution 2
This is only a year old question but it feels like it is a really old one.
Fist - with a version 6.1.0 of 'laravel/homestead" vagrant box you don't need any ssl: true
, it is active by default, however your browser would not know if it can trust the ssl certificate anyway.
The browser trust is a different issue to laravel and homestead, please see this answer to solve it.
Solution 3
It is as I first suspected and mentioned in my comment. You SSL config seems correct since it reports the connection is secure. You are using a self signed certificate, which is fine for development, but it not signed by a recognized Certificate Authority and therefore the browser will not trust it. However once you deploy your project to the general public you will want to purchase a certificate from a recognized Certificate Authority. Once you have that certificate then this error will go away.
Parth Vora
Updated on June 15, 2022Comments
-
Parth Vora almost 2 years
I'm using Laravel Homestead and it is working fine. Now I want to implement HTTPS on one of my sites.
I found that to achieve that you just need to add
ssl: true
into Homestead.yaml and then run vagrant reload --provision.I can see it working when I run above command which shows:
==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Certificate: laravel-cashier.local ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Site: laravel-cashier.local
And in
/etc/nginx/ssl
, I can see these 3 files are created:-rw-r--r-- 1 root root 683 Jul 19 16:26 laravel-cashier.local.cnf -rw-r--r-- 1 root root 1269 Jul 19 16:26 laravel-cashier.local.crt -rw-r--r-- 1 root root 1704 Jul 19 16:26 laravel-cashier.local.key
But what next?
When I'm trying to run the site with https:
Do I need to do any other steps?
Note: I'm using latest Homestead version 2.1.0.
I have already seen many posts, but I think they are too old and doesn't provide exact steps to achieve the result:
https://laracasts.com/discuss/channels/tips/tip-how-to-enable-ssl-in-homestead-20
https://laracasts.com/discuss/channels/servers/homestead-ssl
-
Parth Vora almost 7 yearsok, is there any way I can get fully functional SSL certificate on my local development? I'm using Nginx.
-
Chris Baldwin almost 7 yearsTechnically the SSL connection is working. The connection is encrypted. All the browser is trying to bring to your attention is that the certificate that is being used has not been verified by a certificate authority that the browser recognizes. In development that should not be a problem because you know where the certificate comes from. Once you have the public accessing your site then you will want to change it so other people will know they can trust your site.
-
Chris Baldwin almost 7 yearsYou can always buy a certificate from a certificate authority to use in development, however that seems like an unnecessary development expense to me.
-
Kerry Jones over 6 yearsThis just saved my life
-
Ryan over 6 yearsWhat worked for me was mypcname.local:44300 as mentioned here: laracasts.com/discuss/channels/servers/homestead-ssl/replies/… I didn't know that specifying the port (44300) would be important. My hosts file has
192.168.10.10 mypcname.local
. -
Ryan over 6 yearsThis still hasn't worked for me. The steps seem reasonable, but I've tried them many times, and still my local site says "Not secure" even though it's served via https (via the 44300 port of Homestead).
-
Ryan about 6 yearsI've added a big bounty to my question about getting Chrome or Firefox to accept a local certificate: stackoverflow.com/q/48969083/470749
-
Tim Ramsey about 6 yearsWhat worked for me was to copy the root certificate when following these steps - ca.homestead.homestead.crt
-
Inigo over 5 years@TimRamsey I want to thank you graciously. Your simple comment has just brought to an end about 8 hours of utter frustration. This was the most ridiculous problem I've encountered using Windows for web development in quite some time. I still have no clue why the individual site certificates are being rejected. Madness. Anyway, thank you again.
-
Alexander Taubenkorb about 5 yearsWorked for me only after I imported both certificates:
/etc/nginx/ssl/ca.homestead.homestead.crt
as well as/etc/nginx/ssl/mypage.test.crt
-
w5m almost 5 years@AlexanderTaubenkorb and Tim Ramsey - many thanks! Copying both certificates worked for me too.
-
w5m almost 5 yearsActually, it seems that all of my homestead apps now work nicely via https, even though I've not added a project-specific certificate for each app. I'd therefore conclude that it is only necessary to add the ca.homestead.homestead.crt certificate and not any project-specific ones.
-
Tim Ramsey almost 4 yearsFYI - homestead from my experience isn't good about replacing expired certifications, so you may need run
sudo rm /etc/nginx/ssl/certinquestion.crt
andvagrant reload --provision
if you run into a expired certificate -
MarsAndBack over 2 years
/etc/nginx
exists, however contains no/ssl
folder =(