rails-letsencrypt 0.7.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/controllers/lets_encrypt/verifications_controller.rb +1 -1
- data/app/jobs/lets_encrypt/renew_certificates_job.rb +1 -1
- data/app/models/concerns/lets_encrypt/certificate_issuable.rb +1 -1
- data/app/models/concerns/lets_encrypt/certificate_verifiable.rb +4 -4
- data/app/models/lets_encrypt/certificate.rb +7 -1
- data/lib/generators/lets_encrypt/install_generator.rb +3 -3
- data/lib/letsencrypt.rb +4 -0
- data/lib/letsencrypt/configuration.rb +4 -0
- data/lib/letsencrypt/redis.rb +11 -3
- data/lib/letsencrypt/version.rb +1 -1
- data/lib/tasks/letsencrypt_tasks.rake +7 -4
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fcc6f31e49bb320d23f8dc89e768de5c88edc1cfcb65540d3ff294337908aa6
|
4
|
+
data.tar.gz: 88ebaa8808ab982309be5d3a903b39ba731d68a2f0f7d33fee336316ac0b7ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ba93909e4ec5d883c4d84a41a8b64060079b87c491765736c0d325a8d9df7759f5d9fc21945d3769ccd12388a154eb56604c4dc06c89a01cdc3ebd68189ed0
|
7
|
+
data.tar.gz: 819e3498c99f2037ab520114bc2e1bfa2f6bbce50d05a948dfa3ac1b43fc9cab0630bca1b6d1df294bc89ac4f43b1df18ab417a286f38dec60f2caa5ae66649f
|
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Provide manageable Let's Encrypt Certificate for Rails.
|
4
4
|
|
5
|
+
## Requirement
|
6
|
+
|
7
|
+
* Rails 5+
|
8
|
+
* Ruby 2.5+
|
9
|
+
|
5
10
|
## Installation
|
6
11
|
|
7
12
|
Puts this in your Gemfile:
|
@@ -56,6 +61,10 @@ LetsEncrypt.config do |config|
|
|
56
61
|
# The redis server url
|
57
62
|
# Default is nil
|
58
63
|
config.redis_url = 'redis://localhost:6379/1'
|
64
|
+
|
65
|
+
# Enable it if you want to customize the model
|
66
|
+
# Default is LetsEncrypt::Certificate
|
67
|
+
#config.certificate_model = 'MyCertificate'
|
59
68
|
end
|
60
69
|
```
|
61
70
|
|
@@ -10,7 +10,7 @@ module LetsEncrypt
|
|
10
10
|
logger.info "Getting certificate for #{domain}"
|
11
11
|
create_certificate
|
12
12
|
# rubocop:disable Metrics/LineLength
|
13
|
-
logger.info "Certificate issued (expires on #{expires_at}, will renew after #{renew_after})"
|
13
|
+
logger.info "Certificate issued for #{domain} (expires on #{expires_at}, will renew after #{renew_after})"
|
14
14
|
# rubocop:enable Metrics/LineLength
|
15
15
|
true
|
16
16
|
end
|
@@ -35,7 +35,7 @@ module LetsEncrypt
|
|
35
35
|
until @challenge.status != 'pending'
|
36
36
|
checks += 1
|
37
37
|
if checks > 30
|
38
|
-
logger.info
|
38
|
+
logger.info "#{domain}: Status remained at pending for 30 checks"
|
39
39
|
return false
|
40
40
|
end
|
41
41
|
sleep 1
|
@@ -45,7 +45,7 @@ module LetsEncrypt
|
|
45
45
|
|
46
46
|
def check_verify_status
|
47
47
|
unless @challenge.status == 'valid'
|
48
|
-
logger.info "Status was not valid (was: #{@challenge.status})"
|
48
|
+
logger.info "#{domain}: Status was not valid (was: #{@challenge.status})"
|
49
49
|
return false
|
50
50
|
end
|
51
51
|
|
@@ -56,11 +56,11 @@ module LetsEncrypt
|
|
56
56
|
@retries ||= 0
|
57
57
|
if e.is_a?(Acme::Client::Error::BadNonce) && @retries < 5
|
58
58
|
@retries += 1
|
59
|
-
logger.info "Bad nounce encountered. Retrying (#{@retries} of 5 attempts)"
|
59
|
+
logger.info "#{domain}: Bad nounce encountered. Retrying (#{@retries} of 5 attempts)"
|
60
60
|
sleep 1
|
61
61
|
verify
|
62
62
|
else
|
63
|
-
logger.info "Error: #{e.class} (#{e.message})"
|
63
|
+
logger.info "#{domain}: Error: #{e.class} (#{e.message})"
|
64
64
|
return false
|
65
65
|
end
|
66
66
|
end
|
@@ -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
|
@@ -21,12 +21,12 @@ module LetsEncrypt
|
|
21
21
|
'db/migrate/create_letsencrypt_certificates.rb'
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
Rails::VERSION::MAJOR
|
24
|
+
def required_migration_version?
|
25
|
+
Rails::VERSION::MAJOR >= 5
|
26
26
|
end
|
27
27
|
|
28
28
|
def migration_version
|
29
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if
|
29
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if required_migration_version?
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/letsencrypt.rb
CHANGED
@@ -16,6 +16,10 @@ module LetsEncrypt
|
|
16
16
|
config_accessor :save_to_redis
|
17
17
|
config_accessor :redis_url
|
18
18
|
|
19
|
+
config_accessor :certificate_model do
|
20
|
+
'LetsEncrypt::Certificate'
|
21
|
+
end
|
22
|
+
|
19
23
|
# Returns true if enabled `save_to_redis` feature
|
20
24
|
def use_redis?
|
21
25
|
save_to_redis == true
|
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.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: acme-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,30 +84,30 @@ dependencies:
|
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.16.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.16.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: coveralls
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.8.23
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.8.23
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: codeclimate-test-reporter
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +156,7 @@ homepage: https://github.com/elct9620/rails-letsencrypt
|
|
156
156
|
licenses:
|
157
157
|
- MIT
|
158
158
|
metadata: {}
|
159
|
-
post_install_message:
|
159
|
+
post_install_message:
|
160
160
|
rdoc_options: []
|
161
161
|
require_paths:
|
162
162
|
- lib
|
@@ -171,9 +171,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
|
-
|
175
|
-
|
176
|
-
signing_key:
|
174
|
+
rubygems_version: 3.1.6
|
175
|
+
signing_key:
|
177
176
|
specification_version: 4
|
178
177
|
summary: The Let's Encrypt certificate manager for rails
|
179
178
|
test_files: []
|