anchor-pki 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +29 -8
- data/README.md +3 -5
- data/lib/anchor/auto_cert/configuration.rb +35 -228
- data/lib/anchor/auto_cert/railtie.rb +4 -59
- data/lib/anchor/auto_cert.rb +0 -16
- data/lib/anchor/pem_bundle.rb +2 -0
- data/lib/anchor/version.rb +1 -1
- data/lib/anchor.rb +0 -1
- data/lib/puma/dsl.rb +14 -9
- data/lib/puma/plugin/auto_cert.rb +113 -80
- metadata +4 -29
- data/lib/anchor/auto_cert/identifier_policy.rb +0 -71
- data/lib/anchor/auto_cert/managed_certificate.rb +0 -77
- data/lib/anchor/auto_cert/manager.rb +0 -260
- data/lib/anchor/auto_cert/policy_check/for_hostname.rb +0 -40
- data/lib/anchor/auto_cert/policy_check/for_ipaddr.rb +0 -48
- data/lib/anchor/auto_cert/policy_check/for_wildcard_hostname.rb +0 -57
- data/lib/anchor/auto_cert/policy_check.rb +0 -37
- data/lib/anchor/auto_cert/registry.rb +0 -63
- data/lib/anchor/auto_cert/renewal_busy_wait.rb +0 -40
- data/lib/anchor/auto_cert/terms_of_service_acceptor.rb +0 -34
- data/lib/anchor/disk_store.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 668bda70c37b6cfed433ff05de800a8e2a4f1576a6a16b73d0c653794890938a
|
4
|
+
data.tar.gz: 9c96396faf03bed36249890bd19682988bdbb52d4e5eca4fe7994bbfaddf66f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a8a30a3eb39f5544250bf12338c31d7f3392fda4440a74dc916c28ffac5d2817b8687a911695db06d46f236f7e27857a482abb172854f7d9fd88e5332115749
|
7
|
+
data.tar.gz: 004d41141dcca7ef89f994f726e0502c43957ce0c144d09fc719f71292f9abdc1a7cb45c6a57f75a84debd9ca2ac3f2085778879e104f4349bae51100c46909e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.7.0] - 2024-01-11
|
4
|
+
|
5
|
+
- inherit from the puma-acme plugin in auto\_cert plugin
|
6
|
+
- remove extraneous config & environment settings
|
7
|
+
|
8
|
+
## [0.6.3] - 2024-01-10
|
9
|
+
|
10
|
+
- fixed release (0.6.2 didn't contain the expected changes)
|
11
|
+
|
3
12
|
## [0.6.2] - 2023-12-20
|
4
13
|
|
5
14
|
- make terms of service an optional parameter
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
anchor-pki (0.6.
|
5
|
-
acme
|
6
|
-
pstore (~> 0.1)
|
4
|
+
anchor-pki (0.6.3)
|
5
|
+
puma-acme (~> 0.1)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -19,21 +18,36 @@ GEM
|
|
19
18
|
rexml
|
20
19
|
diff-lcs (1.5.0)
|
21
20
|
docile (1.4.0)
|
22
|
-
faraday (2.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
faraday-net_http (3.0.2)
|
21
|
+
faraday (2.9.0)
|
22
|
+
faraday-net_http (>= 2.0, < 3.2)
|
23
|
+
faraday-net_http (3.1.0)
|
24
|
+
net-http
|
27
25
|
faraday-retry (2.2.0)
|
28
26
|
faraday (~> 2.0)
|
29
27
|
hashdiff (1.0.1)
|
30
28
|
json (2.6.3)
|
31
29
|
minitest (5.18.0)
|
30
|
+
mustermann (3.0.0)
|
31
|
+
ruby2_keywords (~> 0.0.1)
|
32
|
+
net-http (0.4.1)
|
33
|
+
uri
|
34
|
+
nio4r (2.7.0)
|
32
35
|
parallel (1.23.0)
|
33
36
|
parser (3.2.2.1)
|
34
37
|
ast (~> 2.4.1)
|
35
38
|
pstore (0.1.3)
|
36
39
|
public_suffix (5.0.1)
|
40
|
+
puma (6.4.2)
|
41
|
+
nio4r (~> 2.0)
|
42
|
+
puma-acme (0.1.0)
|
43
|
+
acme-client (~> 2.0.13)
|
44
|
+
pstore (~> 0.1)
|
45
|
+
puma (~> 6.4)
|
46
|
+
sinatra (~> 3.1)
|
47
|
+
rack (2.2.8)
|
48
|
+
rack-protection (3.2.0)
|
49
|
+
base64 (>= 0.1.0)
|
50
|
+
rack (~> 2.2, >= 2.2.4)
|
37
51
|
rainbow (3.1.1)
|
38
52
|
rake (13.1.0)
|
39
53
|
regexp_parser (2.8.0)
|
@@ -79,7 +93,14 @@ GEM
|
|
79
93
|
simplecov_json_formatter (~> 0.1)
|
80
94
|
simplecov-html (0.12.3)
|
81
95
|
simplecov_json_formatter (0.1.4)
|
96
|
+
sinatra (3.2.0)
|
97
|
+
mustermann (~> 3.0)
|
98
|
+
rack (~> 2.2, >= 2.2.4)
|
99
|
+
rack-protection (= 3.2.0)
|
100
|
+
tilt (~> 2.0)
|
101
|
+
tilt (2.3.0)
|
82
102
|
unicode-display_width (2.4.2)
|
103
|
+
uri (0.13.0)
|
83
104
|
vcr (6.1.0)
|
84
105
|
webmock (3.18.1)
|
85
106
|
addressable (>= 2.8.0)
|
data/README.md
CHANGED
@@ -8,15 +8,13 @@ The Following environment variables are available to configure the default
|
|
8
8
|
[`AutoCert::Manager`](./lib/anchor/auto_cert/manager.rb).
|
9
9
|
|
10
10
|
* `HTTPS_PORT` - the TCP numerical port to bind SSL to.
|
11
|
-
* `
|
12
|
-
* `ACME_CONTACT` - URL to contact in case of issues with the account
|
11
|
+
* `SERVER_NAME`/`SERVER_NAMES` - A comma separated list of hostnames for provisioning certs
|
13
12
|
* `ACME_DIRECTORY_URL` - the ACME provider's directory
|
14
13
|
* `ACME_HMAC_KEY` - your External Account Binding (EAB) HMAC_KEY for authenticating with the ACME directory above
|
15
14
|
* `ACME_KID` - your External Account Binding (EAB) KID for authenticating with the ACME directory above with an
|
15
|
+
* `ACME_CONTACT` - **optional** URL to contact in case of issues with the account
|
16
16
|
* `ACME_RENEW_BEFORE_SECONDS` - **optional** Start a renewal this number number of seconds before the cert expires. This defaults to 30 days (2592000 seconds)
|
17
17
|
* `ACME_RENEW_BEFORE_FRACTION` - **optional** Start the renewal when this fraction of a cert's valid window is left. This defaults to 0.5, which means when the cert is in the last 50% of its lifespan a renewal is attempted.
|
18
|
-
* `AUTO_CERT_CHECK_EVERY` - **optional** the number of seconds to wait between checking if the certificate has expired. This defaults to 1 hour (3600 seconds)
|
19
|
-
* `AUTO_CERT_NAME` - **optional** the name to use to lookup the default `AutoCert::Configuration` in the `AutoCert::Registry`. This is `default` by default
|
20
18
|
|
21
19
|
If both `ACME_RENEW_BEFORE_SECONDS` and `ACME_RENEW_BEFORE_FRACTION` are set,
|
22
20
|
the one that causes the renewal to take place earlier is used.
|
@@ -39,7 +37,7 @@ Currently the `AutoCert::Manager` will use whichever is earlier.
|
|
39
37
|
|
40
38
|
```sh
|
41
39
|
HTTPS_PORT=44300
|
42
|
-
|
40
|
+
SERVER_NAMES=my.lcl.host,*.my.lcl.host
|
43
41
|
ACME_DIRECTORY_URL=https://acme-v02.api.letsencrypt.org/directory
|
44
42
|
ACME_KID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
45
43
|
ACME_HMAC_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
@@ -1,245 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Anchor
|
4
|
+
# This module is here in order to communicate plugin configuration options
|
5
|
+
# to the plugin since the plugin is created dynamically and it is loaded and
|
6
|
+
# initialized without any configuration options.
|
4
7
|
module AutoCert
|
8
|
+
config_keys = %i[
|
9
|
+
algorithm
|
10
|
+
cache
|
11
|
+
cache_dir
|
12
|
+
contact
|
13
|
+
directory
|
14
|
+
eab_kid
|
15
|
+
eab_hmac_key
|
16
|
+
enabled
|
17
|
+
mode
|
18
|
+
port
|
19
|
+
renew_at
|
20
|
+
renew_interval
|
21
|
+
server_name
|
22
|
+
server_names
|
23
|
+
tos_agreed
|
24
|
+
]
|
25
|
+
|
5
26
|
# AutoCert Configuration provides a way to configure the AutoCert Manager.
|
6
27
|
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
DEFAULT_CHECK_EVERY_SECONDS = 60 * 60 # 1 day in seconds
|
11
|
-
|
12
|
-
# Note - although it is possible to set change the name of a config, it is
|
13
|
-
# not recommended. The name is used as the key in the Registry, and if a
|
14
|
-
# Configuration is in the Registry, and its name is changed, it does not
|
15
|
-
# change its registry key.
|
16
|
-
attr_accessor :name,
|
17
|
-
:allow_identifiers,
|
18
|
-
:cache_dir,
|
19
|
-
:check_every_seconds,
|
20
|
-
:contact,
|
21
|
-
:directory_url,
|
22
|
-
:external_account_binding,
|
23
|
-
:renew_before_fraction,
|
24
|
-
:renew_before_seconds,
|
25
|
-
:tos_acceptors,
|
26
|
-
:work_dir
|
27
|
-
|
28
|
-
# rubocop:disable Metrics/ParameterLists
|
29
|
-
# Data defined classes have all required parameters in the initializer, so
|
30
|
-
# override the default initializer to allow for optional parameters and
|
31
|
-
# to pull in the defaults form the environment
|
32
|
-
#
|
33
|
-
def initialize(name:,
|
34
|
-
allow_identifiers: nil,
|
35
|
-
cache_dir: nil,
|
36
|
-
check_every_seconds: nil,
|
37
|
-
contact: nil,
|
38
|
-
directory_url: nil,
|
39
|
-
external_account_binding: nil,
|
40
|
-
renew_before_fraction: nil,
|
41
|
-
renew_before_seconds: nil,
|
42
|
-
tos_acceptors: nil,
|
43
|
-
work_dir: nil)
|
44
|
-
|
45
|
-
@name = name
|
46
|
-
|
47
|
-
@allow_identifiers = allow_identifiers
|
48
|
-
@cache_dir = cache_dir
|
49
|
-
@check_every_seconds = check_every_seconds
|
50
|
-
@contact = contact
|
51
|
-
@directory_url = directory_url
|
52
|
-
@external_account_binding = external_account_binding
|
53
|
-
@renew_before_fraction = renew_before_fraction
|
54
|
-
@renew_before_seconds = renew_before_seconds
|
55
|
-
@tos_acceptors = tos_acceptors
|
56
|
-
@work_dir = work_dir
|
57
|
-
end
|
58
|
-
# rubocop:enable Metrics/ParameterLists
|
59
|
-
|
60
|
-
def account
|
61
|
-
{
|
62
|
-
contact: contact,
|
63
|
-
external_account_binding: external_account_binding
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
# Enabled just means that the configuration is valid
|
68
|
-
def enabled?
|
69
|
-
validate!
|
70
|
-
true
|
71
|
-
rescue ConfigurationError => _e
|
72
|
-
false
|
73
|
-
end
|
74
|
-
|
75
|
-
def validate!
|
76
|
-
@allow_identifiers = prepare_allow_identifiers(@allow_identifiers)
|
77
|
-
@cache_dir = prepare_directory(dir: @cache_dir, property: 'cache_dir')
|
78
|
-
@check_every_seconds = prepare_check_every_seconds(@check_every_seconds)
|
79
|
-
@contact = prepare_contact(@contact)
|
80
|
-
@directory_url = prepare_directory_url(@directory_url)
|
81
|
-
@external_account_binding = prepare_external_account_binding(@external_account_binding)
|
82
|
-
@renew_before_fraction = prepare_renew_before_fraction(@renew_before_fraction)
|
83
|
-
@renew_before_seconds = prepare_renew_before_seconds(@renew_before_seconds)
|
84
|
-
@tos_acceptors = prepare_tos_acceptors(@tos_acceptors)
|
85
|
-
@work_dir = prepare_directory(dir: @work_dir, property: 'work_dir')
|
86
|
-
self
|
87
|
-
end
|
88
|
-
|
89
|
-
# Return the fallback identifer for this configuration
|
90
|
-
|
91
|
-
# look at all the identifiers, strip a leading wildcard off of all of
|
92
|
-
# them and then pick the one that has the fewest '.' in it, if there are
|
93
|
-
# ties for fewest, pick the first one in the list of ties. A minimum of
|
94
|
-
# 2 '.' is required.
|
95
|
-
#
|
96
|
-
def fallback_identifier
|
97
|
-
de_wildcarded = allow_identifiers.map { |i| i.sub(/^\*\./, '') }
|
98
|
-
not_tld = de_wildcarded.select { |i| i.count('.') >= 2 }
|
99
|
-
ordered = not_tld.sort_by { |i| i.count('.') }
|
100
|
-
ordered[0]
|
101
|
-
end
|
102
|
-
|
103
|
-
private
|
28
|
+
Configuration = Struct.new(*config_keys, keyword_init: true) do
|
29
|
+
alias_method :allow_identifiers=, :server_names=
|
30
|
+
alias_method :directory_url=, :directory=
|
104
31
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
allow_identifiers
|
109
|
-
when String
|
110
|
-
allow_identifiers.split(',')
|
111
|
-
when nil
|
112
|
-
ENV.fetch('ACME_ALLOW_IDENTIFIERS', nil)&.split(',')
|
113
|
-
end
|
32
|
+
def initialize(opts = {})
|
33
|
+
self.directory_url = opts.delete(:directory_url)
|
34
|
+
self.allow_identifiers = opts.delete(:allow_identifiers)
|
114
35
|
|
115
|
-
if
|
116
|
-
|
117
|
-
"The '#{name}' #{self.class} instance has a misconfigured " \
|
118
|
-
'`allow_identifiers` value. Set it to a string, or an array of strings, ' \
|
119
|
-
'or set the ACME_ALLOW_IDENTIFIERS environment variable ' \
|
120
|
-
'to a comma separated list of identifiers.'
|
36
|
+
if (eab = opts.delete(:external_account_binding))
|
37
|
+
self.external_account_binding = eab
|
121
38
|
end
|
122
39
|
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
def prepare_check_every_seconds(check_every_seconds)
|
127
|
-
message = "The '#{name}' #{self.class} instance has a misconfigured " \
|
128
|
-
'`check_every_seconds` value. It must be set to an integer > 0, ' \
|
129
|
-
'or set the AUTO_CERT_CHECK_EVERY environment variable.'
|
130
|
-
|
131
|
-
candidates = [
|
132
|
-
check_every_seconds,
|
133
|
-
ENV.fetch('AUTO_CERT_CHECK_EVERY', nil),
|
134
|
-
DEFAULT_CHECK_EVERY_SECONDS
|
135
|
-
]
|
136
|
-
|
137
|
-
ensure_positive_integer(candidates, message)
|
138
|
-
end
|
139
|
-
|
140
|
-
def prepare_contact(contact)
|
141
|
-
contact ||= ENV.fetch('ACME_CONTACT', nil)
|
142
|
-
|
143
|
-
contact
|
40
|
+
super(opts)
|
144
41
|
end
|
145
42
|
|
146
|
-
def
|
147
|
-
|
148
|
-
'It must be set to a string, or set the ACME_DIRECTORY_URL environment variable.'
|
149
|
-
|
150
|
-
directory_url ||= ENV.fetch('ACME_DIRECTORY_URL', nil)
|
151
|
-
|
152
|
-
raise ConfigurationError, message if directory_url.nil?
|
153
|
-
|
154
|
-
directory_url
|
43
|
+
def server_name=(name)
|
44
|
+
self.server_names = [name]
|
155
45
|
end
|
156
46
|
|
157
|
-
def
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if external_account_binding && external_account_binding[:kid] && external_account_binding[:hmac_key]
|
162
|
-
return external_account_binding
|
163
|
-
end
|
164
|
-
|
165
|
-
{ kid: kid, hmac_key: hmac_key }
|
166
|
-
end
|
167
|
-
|
168
|
-
def prepare_renew_before_seconds(renew_before_seconds)
|
169
|
-
message = "The '#{name}' #{self.class} instance has a misconfigured " \
|
170
|
-
'`before_seconds` value. It must be set to an integer > 0, ' \
|
171
|
-
'or set the ACME_RENEW_BEFORE_SECONDS environment variable.'
|
172
|
-
|
173
|
-
candidates = [
|
174
|
-
renew_before_seconds,
|
175
|
-
ENV.fetch('ACME_RENEW_BEFORE_SECONDS', nil),
|
176
|
-
DEFAULT_RENEW_BEFORE_SECONDS
|
177
|
-
]
|
178
|
-
ensure_positive_integer(candidates, message)
|
179
|
-
end
|
180
|
-
|
181
|
-
def prepare_renew_before_fraction(renew_before_fraction)
|
182
|
-
message = "The '#{name}' #{self.class} instance has a misconfigured " \
|
183
|
-
'`before_fraction` value. It must be set to a float > 0 and < 1, ' \
|
184
|
-
'or set the ACME_RENEW_BEFORE_FRACTION environment variable.'
|
185
|
-
|
186
|
-
candidates = [
|
187
|
-
renew_before_fraction,
|
188
|
-
ENV.fetch('ACME_RENEW_BEFORE_FRACTION', nil),
|
189
|
-
DEFAULT_RENEW_BEFORE_FRACTION
|
190
|
-
]
|
191
|
-
|
192
|
-
candidates.each do |candidate|
|
193
|
-
next if candidate.nil?
|
194
|
-
|
195
|
-
as_float = candidate.to_f
|
196
|
-
return as_float if (0..1).cover?(as_float)
|
197
|
-
end
|
198
|
-
|
199
|
-
# this should really never happen as DEFAULT_RENEW_BEFORE_FRACTION is
|
200
|
-
# valid
|
201
|
-
raise ConfigurationError, message
|
202
|
-
end
|
203
|
-
|
204
|
-
def prepare_tos_acceptors(tos_acceptors)
|
205
|
-
tos_acceptors = Array(tos_acceptors)
|
206
|
-
|
207
|
-
if tos_acceptors.empty? || tos_acceptors.any? { |tos| !tos.respond_to?(:accept?) }
|
208
|
-
raise ConfigurationError,
|
209
|
-
"The '#{name}' #{self.class} instance has a misconfigured " \
|
210
|
-
'`tos_acceptors` value. It must be set to an object ' \
|
211
|
-
'or an array of objects that respond to `accept?`.'
|
212
|
-
end
|
213
|
-
|
214
|
-
tos_acceptors
|
215
|
-
end
|
216
|
-
|
217
|
-
def prepare_directory(dir:, property:)
|
218
|
-
return nil if dir.nil?
|
219
|
-
|
220
|
-
dir = Pathname.new(dir) unless dir.is_a?(Pathname)
|
221
|
-
message = "The '#{name}' #{self.class} instance has a misconfigured " \
|
222
|
-
"`#{property}` value, it resolves to (#{dir}). " \
|
223
|
-
'It must be set to a directory, or a path that can be created.'
|
224
|
-
|
225
|
-
begin
|
226
|
-
dir.mkpath
|
227
|
-
rescue StandardError => _e
|
228
|
-
raise ConfigurationError, message
|
229
|
-
end
|
230
|
-
|
231
|
-
dir
|
232
|
-
end
|
233
|
-
|
234
|
-
def ensure_positive_integer(candidates, message)
|
235
|
-
candidates.each do |candidate|
|
236
|
-
next if candidate.nil?
|
237
|
-
|
238
|
-
as_int = candidate.to_i
|
239
|
-
return as_int if as_int.positive?
|
240
|
-
end
|
241
|
-
|
242
|
-
raise ConfigurationError, message
|
47
|
+
def external_account_binding=(eab)
|
48
|
+
self.eab_kid = eab[:kid]
|
49
|
+
self.eab_hmac_key = eab[:hmac_key]
|
243
50
|
end
|
244
51
|
end
|
245
52
|
end
|
@@ -6,32 +6,14 @@ module Anchor
|
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
# Initialize the configuration with a blank configuration, ensuring
|
8
8
|
# the configuration exists, even if it is not used.
|
9
|
-
config.auto_cert = ::Anchor::AutoCert::Configuration.new
|
10
|
-
|
11
|
-
# Make sure the auto cert configuration is valid before the app boots
|
12
|
-
# This will run after every code reload in development and after boot in
|
13
|
-
# production
|
14
|
-
config.to_prepare do
|
15
|
-
if Rails.configuration.auto_cert.enabled?
|
16
|
-
Rails.configuration.auto_cert.validate!
|
17
|
-
|
18
|
-
# register the configuration under its name so that it can
|
19
|
-
# be discovered by other parts of the application
|
20
|
-
auto_cert_config = Rails.configuration.auto_cert
|
21
|
-
unless ::Anchor::AutoCert::Registry.key?(auto_cert_config.name)
|
22
|
-
::Anchor::AutoCert::Registry.store(auto_cert_config.name, auto_cert_config)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
9
|
+
config.auto_cert = ::Anchor::AutoCert::Configuration.new
|
26
10
|
|
27
11
|
# this needs to be after the load_config_initializers so that the
|
28
12
|
# application can override the :rails auto_cert configuration
|
29
13
|
#
|
30
|
-
initializer 'auto_cert.configure_rails_initialization', after: :load_config_initializers do |app|
|
31
|
-
auto_cert_config = Railtie.determine_configuration(app)
|
32
|
-
app.config.auto_cert = auto_cert_config
|
33
14
|
|
34
|
-
|
15
|
+
initializer 'auto_cert.configure_rails_initialization', after: :load_config_initializers do |app|
|
16
|
+
# Update the app.config.hosts with the server_names if we are NOT
|
35
17
|
# in the test environment.
|
36
18
|
#
|
37
19
|
# In the test environment `config.hosts` is normally empty, and as a
|
@@ -39,10 +21,7 @@ module Anchor
|
|
39
21
|
# to the `config.hosts` then HostAuthorization will be used, and tests
|
40
22
|
# will break.
|
41
23
|
unless Rails.env.test?
|
42
|
-
|
43
|
-
auto_cert_config&.validate! if Rails.configuration.auto_cert.enabled?
|
44
|
-
|
45
|
-
auto_cert_config&.allow_identifiers&.each do |identifier|
|
24
|
+
app.config.auto_cert[:server_names]&.each do |identifier|
|
46
25
|
# need to convert an identifier into a host matcher, which is just
|
47
26
|
# strip off a leading '*' if it exists so that all subdomains match.
|
48
27
|
#
|
@@ -52,40 +31,6 @@ module Anchor
|
|
52
31
|
end
|
53
32
|
end
|
54
33
|
end
|
55
|
-
|
56
|
-
def self.determine_configuration(app)
|
57
|
-
auto_cert_config = app.config.auto_cert
|
58
|
-
|
59
|
-
# If no configuration is set, then try to lookup one under the :rails
|
60
|
-
# key or create a default one.
|
61
|
-
begin
|
62
|
-
auto_cert_config ||= ::Anchor::AutoCert::Registry.fetch(:rails)
|
63
|
-
rescue KeyError
|
64
|
-
auto_cert_config = Railtie.try_to_create_default_configuration
|
65
|
-
end
|
66
|
-
|
67
|
-
return nil unless auto_cert_config
|
68
|
-
|
69
|
-
# Set some reasonable defaults for a scratch locations if they are not
|
70
|
-
# set explicitly.
|
71
|
-
acme_scratch_dir = app.root / 'tmp' / 'acme'
|
72
|
-
acme_scratch_dir.mkpath
|
73
|
-
auto_cert_config.cache_dir ||= (acme_scratch_dir / 'cache')
|
74
|
-
auto_cert_config.work_dir ||= (acme_scratch_dir / 'work')
|
75
|
-
|
76
|
-
auto_cert_config
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.try_to_create_default_configuration
|
80
|
-
# If it doesn't exist, create a new one - now this may raise an error
|
81
|
-
# if the configuration is not setup correctly
|
82
|
-
::Anchor::AutoCert::Configuration.new(name: :rails)
|
83
|
-
rescue ConfigurationError => e
|
84
|
-
# its fine to not have a coniguration, just log the error and move on
|
85
|
-
msg = "[AutoCert] Unable to create the :rails configuration : #{e.message}"
|
86
|
-
Rails.logger.error(msg)
|
87
|
-
nil
|
88
|
-
end
|
89
34
|
end
|
90
35
|
end
|
91
36
|
end
|
data/lib/anchor/auto_cert.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module Anchor
|
4
|
-
module AutoCert
|
5
|
-
class Error < StandardError; end
|
6
|
-
class IdentifierNotAllowedError < Error; end
|
7
|
-
class ConfigurationError < Error; end
|
8
|
-
class UnknownPolicyCheckError < Error; end
|
9
|
-
class UnknownAlgorithmError < Error; end
|
10
|
-
class UnknownKeyFormatError < Error; end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
require_relative 'auto_cert/terms_of_service_acceptor'
|
14
3
|
require_relative 'auto_cert/configuration'
|
15
|
-
require_relative 'auto_cert/manager'
|
16
|
-
require_relative 'auto_cert/managed_certificate'
|
17
|
-
require_relative 'auto_cert/identifier_policy'
|
18
|
-
require_relative 'auto_cert/registry'
|
19
|
-
require_relative 'auto_cert/renewal_busy_wait'
|
20
4
|
|
21
5
|
require_relative 'auto_cert/railtie' if defined?(Rails::Railtie)
|
data/lib/anchor/pem_bundle.rb
CHANGED
data/lib/anchor/version.rb
CHANGED
data/lib/anchor.rb
CHANGED
data/lib/puma/dsl.rb
CHANGED
@@ -6,23 +6,28 @@
|
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'puma/dsl'
|
9
|
+
require 'puma/acme/dsl'
|
9
10
|
|
10
11
|
module Puma
|
11
12
|
# Extend the ::Puma::DSL module with the configuration options we want
|
12
13
|
class DSL
|
13
|
-
def auto_cert_name(name = nil)
|
14
|
-
@options[:auto_cert_name] = name if name
|
15
|
-
@options[:auto_cert_name]
|
16
|
-
end
|
17
|
-
|
18
14
|
def auto_cert_port(port = nil)
|
19
15
|
@options[:auto_cert_port] = port if port
|
20
16
|
@options[:auto_cert_port]
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
alias auto_cert_algorithm acme_algorithm
|
20
|
+
alias auto_cert_cache acme_cache
|
21
|
+
alias auto_cert_cache_dir acme_cache_dir
|
22
|
+
alias auto_cert_contact acme_contact
|
23
|
+
alias auto_cert_directory acme_directory
|
24
|
+
alias auto_cert_eab_kid acme_eab_kid
|
25
|
+
alias auto_cert_eab_hmac_key acme_eab_hmac_key
|
26
|
+
alias auto_cert_mode acme_mode
|
27
|
+
alias auto_cert_renew_at acme_renew_at
|
28
|
+
alias auto_cert_renew_interval acme_renew_interval
|
29
|
+
alias auto_cert_server_name acme_server_name
|
30
|
+
alias auto_cert_server_names acme_server_names
|
31
|
+
alias auto_cert_tos_agreed acme_tos_agreed
|
27
32
|
end
|
28
33
|
end
|