Skip to content

Commit e8f58d5

Browse files
authored
Merge pull request #11 from Daanra/prepare-0.3
Release v0.3.0
2 parents bf6cdab + 25dd96e commit e8f58d5

22 files changed

+702
-29
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ Creating a new SSL certificate for a specific domain is easy:
6060
\Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::createNow('mydomain.com');
6161
```
6262

63+
Alternative syntax available from v0.3.0:
64+
65+
```php
66+
LetsEncrypt::certificate('mydomain.com')
67+
->chain([
68+
new SomeJob()
69+
])
70+
->delay(5)
71+
->retryAfter(4)
72+
->setTries(4)
73+
->setRetryList([1, 5, 10])
74+
->create(); // or ->renew()
75+
```
76+
77+
Where you can specify values for all jobs:
78+
79+
- tries (The number of times the job may be attempted)
80+
- retryAfter (The number of seconds to wait before retrying the job)
81+
- retryList (The list of seconds to wait before retrying the job)
82+
- chain (Chain some jobs after the certificate has successfully been obtained)
83+
- delay (Set the desired delay for the job)
84+
6385
You could also achieve the same by using an artisan command:
6486
```bash
6587
php artisan lets-encrypt:create -d mydomain.com
@@ -84,6 +106,23 @@ $certificate->delete();
84106
$certificate->forceDelete();
85107
```
86108

109+
## Failure events
110+
111+
If one of the jobs fails, one of the following events will be dispatched:
112+
```php
113+
Daanra\LaravelLetsEncrypt\Events\CleanUpChallengeFailed
114+
Daanra\LaravelLetsEncrypt\Events\ChallengeAuthorizationFailed
115+
Daanra\LaravelLetsEncrypt\Events\RegisterAccountFailed
116+
Daanra\LaravelLetsEncrypt\Events\RequestAuthorizationFailed
117+
Daanra\LaravelLetsEncrypt\Events\RequestCertificateFailed
118+
Daanra\LaravelLetsEncrypt\Events\StoreCertificateFailed
119+
Daanra\LaravelLetsEncrypt\Events\RenewExpiringCertificatesFailed
120+
```
121+
122+
Every event implements the `Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed` interface so you can listen for that as well.
123+
124+
## Automatically renewing certificates
125+
87126
Certificates are valid for 90 days. Before those 90 days are over, you will want to renew them. To do so, you
88127
could add the following to your `App\Console\Kernel`:
89128
```php
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class ChallengeAuthorizationFailed implements LetsEncryptCertificateFailed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/** @var \Throwable */
15+
protected $exception;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct(\Throwable $exception)
23+
{
24+
$this->exception = $exception;
25+
}
26+
27+
public function getException(): \Throwable
28+
{
29+
return $this->exception;
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class CleanUpChallengeFailed implements LetsEncryptCertificateFailed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/** @var \Throwable */
15+
protected $exception;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct(\Throwable $exception)
23+
{
24+
$this->exception = $exception;
25+
}
26+
27+
public function getException(): \Throwable
28+
{
29+
return $this->exception;
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class RegisterAccountFailed implements LetsEncryptCertificateFailed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/** @var \Throwable */
15+
protected $exception;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct(\Throwable $exception)
23+
{
24+
$this->exception = $exception;
25+
}
26+
27+
public function getException(): \Throwable
28+
{
29+
return $this->exception;
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class RenewExpiringCertificatesFailed implements LetsEncryptCertificateFailed
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/** @var \Throwable */
15+
protected $exception;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct(\Throwable $exception)
23+
{
24+
$this->exception = $exception;
25+
}
26+
27+
public function getException(): \Throwable
28+
{
29+
return $this->exception;
30+
}
31+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate;
7+
use Illuminate\Broadcasting\InteractsWithSockets;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class RequestAuthorizationFailed implements LetsEncryptCertificateFailed
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
/** @var \Throwable */
16+
protected $exception;
17+
18+
/** @var LetsEncryptCertificate */
19+
protected $certificate;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @return void
25+
*/
26+
public function __construct(\Throwable $exception, LetsEncryptCertificate $certificate)
27+
{
28+
$this->exception = $exception;
29+
$this->certificate = $certificate;
30+
}
31+
32+
public function getException(): \Throwable
33+
{
34+
return $this->exception;
35+
}
36+
37+
38+
public function getCertificate(): LetsEncryptCertificate
39+
{
40+
return $this->certificate;
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate;
7+
use Illuminate\Broadcasting\InteractsWithSockets;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class RequestCertificateFailed implements LetsEncryptCertificateFailed
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
/** @var \Throwable */
16+
protected $exception;
17+
18+
/** @var LetsEncryptCertificate */
19+
protected $certificate;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @return void
25+
*/
26+
public function __construct(\Throwable $exception, LetsEncryptCertificate $certificate)
27+
{
28+
$this->exception = $exception;
29+
$this->certificate = $certificate;
30+
}
31+
32+
public function getException(): \Throwable
33+
{
34+
return $this->exception;
35+
}
36+
37+
public function getCertificate(): LetsEncryptCertificate
38+
{
39+
return $this->certificate;
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Events;
4+
5+
use Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed;
6+
use Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate;
7+
use Illuminate\Broadcasting\InteractsWithSockets;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class StoreCertificateFailed implements LetsEncryptCertificateFailed
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
/** @var \Throwable */
16+
protected $exception;
17+
18+
/** @var LetsEncryptCertificate */
19+
protected $certificate;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @return void
25+
*/
26+
public function __construct(\Throwable $exception, LetsEncryptCertificate $certificate)
27+
{
28+
$this->exception = $exception;
29+
$this->certificate = $certificate;
30+
}
31+
32+
public function getException(): \Throwable
33+
{
34+
return $this->exception;
35+
}
36+
37+
public function getCertificate(): LetsEncryptCertificate
38+
{
39+
return $this->certificate;
40+
}
41+
}

src/Facades/LetsEncrypt.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Daanra\LaravelLetsEncrypt\Facades;
44

55
use Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate;
6+
use Daanra\LaravelLetsEncrypt\PendingCertificate;
67
use Illuminate\Foundation\Bus\PendingDispatch;
78
use Illuminate\Support\Facades\Facade;
89

@@ -12,6 +13,7 @@
1213
* @method static LetsEncryptCertificate createNow(string $domain)
1314
* @method static LetsEncryptCertificate renewNow(string|LetsEncryptCertificate $domain)
1415
* @method static PendingDispatch renew(string|LetsEncryptCertificate $domain, array $chain = [])
16+
* @method static PendingCertificate certificate(string $domain)
1517
*/
1618
class LetsEncrypt extends Facade
1719
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Daanra\LaravelLetsEncrypt\Interfaces;
4+
5+
interface LetsEncryptCertificateFailed
6+
{
7+
public function getException(): \Throwable;
8+
}

0 commit comments

Comments
 (0)