All Projects → Daanra → laravel-lets-encrypt

Daanra / laravel-lets-encrypt

Licence: MIT license
Let's Encrypt wrapper for Laravel

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-lets-encrypt

Lexicon
Manipulate DNS records on various DNS providers in a standardized way.
Stars: ✭ 1,028 (+817.86%)
Mutual labels:  letsencrypt, ssl-certificate
Dnsrobocert
Orchestrate Certbot and Lexicon together to provide Let's Encrypt TLS certificates validated by DNS challenges
Stars: ✭ 420 (+275%)
Mutual labels:  letsencrypt, ssl-certificate
Intranet-Lets-Encrypt-Certification
Guide to setting up a Let's Encrypt SSL certificate for a non-public facing server.
Stars: ✭ 27 (-75.89%)
Mutual labels:  letsencrypt, ssl-certificate
Letsencrypt Cpanel
cPanel/WHM plugin for Let's Encrypt client
Stars: ✭ 181 (+61.61%)
Mutual labels:  letsencrypt, ssl-certificate
Uacme
ACMEv2 client written in plain C with minimal dependencies
Stars: ✭ 155 (+38.39%)
Mutual labels:  letsencrypt, ssl-certificate
Getssl
obtain free SSL certificates from letsencrypt ACME server Suitable for automating the process on remote servers.
Stars: ✭ 1,687 (+1406.25%)
Mutual labels:  letsencrypt, ssl-certificate
django-yadpt-starter
Yet Another Django Project Template skeleton for Django projects
Stars: ✭ 28 (-75%)
Mutual labels:  letsencrypt, ssl-certificate
Lua Resty Auto Ssl
On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.
Stars: ✭ 1,786 (+1494.64%)
Mutual labels:  letsencrypt, ssl-certificate
Nginxconfig.io
⚙️ NGINX config generator on steroids 💉
Stars: ✭ 14,983 (+13277.68%)
Mutual labels:  letsencrypt, ssl-certificate
Letsencrypt Rails Heroku
Automatic LetsEncrypt SSL certificates in your Rails app on Heroku.
Stars: ✭ 223 (+99.11%)
Mutual labels:  letsencrypt, ssl-certificate
txacme
Twisted client for the ACME (Automatic Certificate Management Environment) protocol
Stars: ✭ 42 (-62.5%)
Mutual labels:  letsencrypt
MailDemon
Smtp server for mass emailing, managing email lists and more. Built on .NET Core. Linux, MAC and Windows compatible.
Stars: ✭ 113 (+0.89%)
Mutual labels:  ssl-certificate
docker-iot-dashboard
A complete IoT server for LoRaWAN IoT projects: node-red + influxdb + grafana + ssl + let's encrypt using docker-compose.
Stars: ✭ 79 (-29.46%)
Mutual labels:  letsencrypt
flynn-certbot
A Certbot that you can run on your Flynn cluster
Stars: ✭ 22 (-80.36%)
Mutual labels:  letsencrypt
aks-letsencrypt
Guide to setup Let's Encrypt on AKS
Stars: ✭ 87 (-22.32%)
Mutual labels:  letsencrypt
mailserver
Simple and full-featured mail server using Docker
Stars: ✭ 88 (-21.43%)
Mutual labels:  letsencrypt
AzureWebAppSSLManager
Acquires and manages free SSL certificates for Azure Web App and Azure Functions applications.
Stars: ✭ 70 (-37.5%)
Mutual labels:  letsencrypt
qiniu-auto-cert
七牛 CDN 证书自动化工具
Stars: ✭ 20 (-82.14%)
Mutual labels:  letsencrypt
roxy
Roxy the Frontend Proxy
Stars: ✭ 52 (-53.57%)
Mutual labels:  letsencrypt
docker-letsencrypt-django-nginx-proxy-uwsgi-postgres
Docker + Letsencrypt + Django + Nginx-Proxy + uWSGI 教學
Stars: ✭ 26 (-76.79%)
Mutual labels:  letsencrypt

Let's Encrypt Laravel

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A Laravel package for easily generating and renewing SSL certificates using Let's Encrypt. This package is especially useful if you have a Laravel application that manages the SSL certificates of many domains. This package is not recommended if you just need to generate a single SSL certificate for your application.

This package is essentially a Laravel-friendly wrapper around Acme PHP.

Installation

You can install the package via composer:

composer require daanra/laravel-lets-encrypt

If you're having installation problems with conflicting dependencies caused by Guzzle then you might want to run:

composer require daanra/laravel-lets-encrypt guzzlehttp/guzzle:^6.0  -w

Publish the configuration file and the migration:

php artisan vendor:publish --provider="Daanra\LaravelLetsEncrypt\LetsEncryptServiceProvider" --tag="lets-encrypt"

Run the migration:

php artisan migrate

Note:

You somehow have to return a stored challenge whenever it it retrieved from the /.well-known/acme-challenge endpoint. You could do this by configuring NGINX/Apache appropriately or by registering a route:

Route::get('/.well-known/acme-challenge/{token}', function (string $token) {
    return \Illuminate\Support\Facades\Storage::get('public/.well-known/acme-challenge/' . $token);
})

Sometimes the /.well-known/ prefix is disabled by default in the NGINX/Apache config (see #4). Make sure it is forwarded to your Laravel application if you want Laravel to return the challenge.

Usage

Creating a new SSL certificate for a specific domain is easy:

// Puts several jobs on the queue to handle the communication with the lets-encrypt server
[$certificate, $pendingDispatch] = \Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::create('mydomain.com');

// You could, for example, chain some jobs to enable a new virtual host
// in Apache and send a notification once the website is available
[$certificate, $pendingDispatch] = \Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::create('mydomain.com', [
    new CreateNewApacheVirtualHost('mydomain.com'), 
    new ReloadApache(),
    new NotifyUserOfNewCertificate(request()->user()),
]);

// You can also do it synchronously:
\Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::createNow('mydomain.com');

Alternative syntax available from v0.3.0:

LetsEncrypt::certificate('mydomain.com')
            ->chain([
                new SomeJob()
            ])
            ->delay(5)
            ->retryAfter(4)
            ->setTries(4)
            ->setRetryList([1, 5, 10])
            ->create(); // or ->renew()

Where you can specify values for all jobs:

  • tries (The number of times the job may be attempted)
  • retryAfter (The number of seconds to wait before retrying the job)
  • retryList (The list of seconds to wait before retrying the job)
  • chain (Chain some jobs after the certificate has successfully been obtained)
  • delay (Set the desired delay for the job)

You could also achieve the same by using an artisan command:

php artisan lets-encrypt:create -d mydomain.com

Certificates are stored in the database. You can query them like so:

// All certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::all();
// All expired certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->expired()->get();
// All currently valid certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->valid()->get();
// All certificates that should be renewed (because they're more than 60 days old)
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->requiresRenewal()->get();

// Find certificate by domain
$certificate = LetsEncryptCertificate::where('domain', 'mydomain.com')->first();
// If you no longer need it, you can soft delete
$certificate->delete();
// Or use a hard delete
$certificate->forceDelete();

Subject Alternative Names

It's also possible to specify Subject Alternative Names as below (requires >= 0.5.0):

LetsEncrypt::certificate('mydomain.com')
        ->setSubjectAlternativeNames(['mydomain2.com'])
        ->create(); 

Failure events

If one of the jobs fails, one of the following events will be dispatched:

Daanra\LaravelLetsEncrypt\Events\CleanUpChallengeFailed
Daanra\LaravelLetsEncrypt\Events\ChallengeAuthorizationFailed
Daanra\LaravelLetsEncrypt\Events\RegisterAccountFailed
Daanra\LaravelLetsEncrypt\Events\RequestAuthorizationFailed
Daanra\LaravelLetsEncrypt\Events\RequestCertificateFailed
Daanra\LaravelLetsEncrypt\Events\StoreCertificateFailed
Daanra\LaravelLetsEncrypt\Events\RenewExpiringCertificatesFailed

Every event implements the Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed interface so you can listen for that as well.

Automatically renewing certificates

Certificates are valid for 90 days. Before those 90 days are over, you will want to renew them. To do so, you could add the following to your App\Console\Kernel:

protected function schedule(Schedule $schedule)
{
    $schedule->job(new \Daanra\LaravelLetsEncrypt\Jobs\RenewExpiringCertificates)->daily();
}

This will automatically renew every certificate that is older than 60 days, ensuring that they never expire.

Configuration

By default this package will use Let's Encrypt's staging server to issue certificates. You should set:

LETS_ENCRYPT_API_URL=https://acme-v02.api.letsencrypt.org/directory

in the .env file of your production server.

By default, this package will attempt to validate a certificate using a HTTP-01 challenge. For this reason, a file will be temporarily stored in your application's storage directory under the path app/public/.well-known/acme-challenge/<CHALLENGE_TOKEN>. You can customise this behavior by setting a custom PathGenerator class in your config under path_generator. Note that Let's Encrypt expects the following path:

/.well-known/acme-challenge/<CHALLENGE_TOKEN>

to return the contents of the file located at $pathGenerator->getPath($token).

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker. If you have a question, please open an issue instead of sending an email.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].