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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cd16f726ca1f16ff33db2bdde9c5d3e13310ac875d475f209761c3e7e5115bf
4
- data.tar.gz: 7868c273d7d2058e08b02e6b1561c9222c7132c9cc8c8a604404bee90ec95b5c
3
+ metadata.gz: c66c89051c25749cc81ea2c424a44906bb6dc7919a8dcf1f1232545cae89ccd2
4
+ data.tar.gz: 15e4fd11a59a9785cc1f082a9892eb8d6f55da8d7eaac7e7031bc56c4b6fb1c0
5
5
  SHA512:
6
- metadata.gz: f8b31a39a0eaa18e1aaca42db86e225560db6d6275ab9d11ca128180175bae0bc4c13bacd7f134eb81e2fe7544d4478cbd6447f18706f953ee0d790f33d5542e
7
- data.tar.gz: d31bfb345ccf6d730a9b0f355be6885feb3e7ff24d55dfdf5fbc530bbe1583489496fd23d3dfd4bcce5ea190539fb6d194347171a8b26a916090323f114c3dd2
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
@@ -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.certificate.present?
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.certificate
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LetsEncrypt
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.0'
5
5
  end
@@ -1,17 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :letsencrypt do
4
- desc 'Renew the certificates will epxired'
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
- log "Could not renew domain: #{certificate.domain}"
15
+ puts "Could not renew domain: #{certificate.domain}"
13
16
  end
14
17
 
15
- puts "Total #{count} domains should renew, and #{failed} domains cannot be renewed."
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.8.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-02-11 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails