rails-letsencrypt 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/lets_encrypt/certificate.rb +7 -1
- data/lib/letsencrypt/redis.rb +11 -3
- data/lib/letsencrypt/version.rb +1 -1
- data/lib/tasks/letsencrypt_tasks.rake +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c66c89051c25749cc81ea2c424a44906bb6dc7919a8dcf1f1232545cae89ccd2
|
4
|
+
data.tar.gz: 15e4fd11a59a9785cc1f082a9892eb8d6f55da8d7eaac7e7031bc56c4b6fb1c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95fc3af7a3f89e95e4b50ed67ae0c1ed0ec21e3f1dd8c8a8563d5154f38acb23e6350d622bfc5104f89ac4274b8b0da84da9a34db49420eaf860d38d5e4ee9cb
|
7
|
+
data.tar.gz: 5743cc2eefdd22bcd211651add527f0f0e6df56f0fe085cb8da6e5cdae071b16e372f9a8e7a72f4a8e51615fd08894b00be3db493e663806132b5695f114d0e0
|
@@ -34,6 +34,7 @@ module LetsEncrypt
|
|
34
34
|
|
35
35
|
before_create -> { self.key = OpenSSL::PKey::RSA.new(4096).to_s }
|
36
36
|
after_save -> { save_to_redis }, if: -> { LetsEncrypt.config.use_redis? && active? }
|
37
|
+
after_destroy -> { delete_from_redis }, if: -> { LetsEncrypt.config.use_redis? && active? }
|
37
38
|
|
38
39
|
# Returns false if certificate is not issued.
|
39
40
|
#
|
@@ -57,7 +58,7 @@ module LetsEncrypt
|
|
57
58
|
|
58
59
|
# Returns full-chain bundled certificates
|
59
60
|
def bundle
|
60
|
-
certificate + intermediaries
|
61
|
+
(certificate || '') + (intermediaries || '')
|
61
62
|
end
|
62
63
|
|
63
64
|
def certificate_object
|
@@ -73,6 +74,11 @@ module LetsEncrypt
|
|
73
74
|
LetsEncrypt::Redis.save(self)
|
74
75
|
end
|
75
76
|
|
77
|
+
# Delete certificate from redis
|
78
|
+
def delete_from_redis
|
79
|
+
LetsEncrypt::Redis.delete(self)
|
80
|
+
end
|
81
|
+
|
76
82
|
protected
|
77
83
|
|
78
84
|
def logger
|
data/lib/letsencrypt/redis.rb
CHANGED
@@ -10,10 +10,18 @@ module LetsEncrypt
|
|
10
10
|
|
11
11
|
# Save certificate into redis.
|
12
12
|
def save(cert)
|
13
|
-
return unless cert.key.present? && cert.
|
14
|
-
LetsEncrypt.logger.info "Save #{cert.domain}'s certificate to redis"
|
13
|
+
return unless cert.key.present? && cert.bundle.present?
|
14
|
+
LetsEncrypt.logger.info "Save #{cert.domain}'s certificate (bundle) to redis"
|
15
15
|
connection.set "#{cert.domain}.key", cert.key
|
16
|
-
connection.set "#{cert.domain}.crt", cert.
|
16
|
+
connection.set "#{cert.domain}.crt", cert.bundle
|
17
|
+
end
|
18
|
+
|
19
|
+
# Delete certificate from redis.
|
20
|
+
def delete(cert)
|
21
|
+
return unless cert.key.present? && cert.certificate.present?
|
22
|
+
LetsEncrypt.logger.info "Delete #{cert.domain}'s certificate from redis"
|
23
|
+
connection.del "#{cert.domain}.key"
|
24
|
+
connection.del "#{cert.domain}.crt"
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
data/lib/letsencrypt/version.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :letsencrypt do
|
4
|
-
desc
|
4
|
+
desc "Renew certificates that already expired or expiring soon"
|
5
5
|
task renew: :environment do
|
6
6
|
count = 0
|
7
7
|
failed = 0
|
8
|
+
|
8
9
|
LetsEncrypt.certificate_model.renewable.each do |certificate|
|
9
10
|
count += 1
|
11
|
+
|
10
12
|
next if certificate.renew
|
13
|
+
|
11
14
|
failed += 1
|
12
|
-
|
15
|
+
puts "Could not renew domain: #{certificate.domain}"
|
13
16
|
end
|
14
17
|
|
15
|
-
puts "
|
18
|
+
puts "Renewed #{count - failed} out of #{count} domains"
|
16
19
|
end
|
17
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-letsencrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|