acmesmith 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1800e04848970a25e7d2269f2b9a1351c7fc524559a00e4d9be970253ee84da7
4
- data.tar.gz: 9ef3bf5fa577c0b0e365f9543bcd1e9732230df888e9baf7c443b7b7b02e178e
3
+ metadata.gz: '00710093e0dc9f9ec6ba1d54bf67585d45efa053e8a6bd7250c638abfce17908'
4
+ data.tar.gz: ecff83969fbf75e8566f1f75638b35937615af3d9fe05a759663d1a82b5d11af
5
5
  SHA512:
6
- metadata.gz: ec36a85fdb1757428338a49406240ac0066b2e058cc07938782db9e739f5afcfa91386085733038983ccce91e6fd7e71924d531be33a5b22492dff36d5e5f947
7
- data.tar.gz: 624517367e2c044b59aa6821f8936ccc941a1ba7954aceaf47c8ff74098f129186fe8ba97efa3e213aea5b153f54fa9fd0675c7791b75c4efc9ed8482ee71887
6
+ metadata.gz: 6df65f1bef30badd2f6691bebeeadf2548d878404a31b166a8fb607aae1027c02345162db7068bb3eb276718aae819dd31ec0188a6075d6fd69d28252d4c79d6
7
+ data.tar.gz: c2689ab6ffcd876a5af2c7c4b25c1b4b2553c20c07472b8698d1b43787ad2ed5bac72354381aa76b4da6fb64fd5a2f60b2ee09006f58caa1b16083e12067e391
@@ -18,20 +18,13 @@ jobs:
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- ruby-version: ['3.1', '3.2', '3.3']
22
- container:
23
- image: public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev
21
+ ruby-version: ['3.2', '3.3', '3.4']
24
22
  steps:
25
-
26
- - name: Cache bundled gems
27
- uses: actions/cache@v1
28
- id: rspec-bundle
29
- with:
30
- path: ~/bundle
31
- key: ${{ runner.os }}-${{ matrix.ruby-version }}
32
-
33
23
  - uses: actions/checkout@master
34
- - run: 'bundle install --path ~/bundle'
24
+ - uses: sorah-rbpkg/actions@v2
25
+ with:
26
+ ruby-version: "${{ matrix.ruby-version }}"
27
+ bundler-cache: true
35
28
  - run: 'bundle exec rspec -fd'
36
29
 
37
30
  integration-pebble:
@@ -40,7 +33,7 @@ jobs:
40
33
  strategy:
41
34
  fail-fast: false
42
35
  matrix:
43
- ruby-version: ['3.1', '3.2', '3.3']
36
+ ruby-version: ['3.2', '3.3', '3.4']
44
37
 
45
38
  # FIXME: once GitHub Actions gains support of adding command line arguments to container
46
39
  # services:
@@ -63,16 +56,14 @@ jobs:
63
56
  steps:
64
57
  - uses: actions/checkout@master
65
58
 
66
- - name: Cache bundled gems
67
- uses: actions/cache@v1
68
- id: instegration-pebble-bundle
59
+ - uses: sorah-rbpkg/actions@v2
69
60
  with:
70
- path: ~/bundle
71
- key: ${{ runner.os }}-${{ matrix.ruby-version }}
61
+ ruby-version: "${{ matrix.ruby-version }}"
62
+ bundler-cache: true
72
63
 
73
64
  - run: 'docker run -d --net=host --rm letsencrypt/pebble pebble -config /test/config/pebble-config.json -strict -dnsserver 127.0.0.1:8053'
74
65
  - run: 'docker run -d --net=host --rm letsencrypt/pebble-challtestsrv pebble-challtestsrv -management :8055 -defaultIPv4 127.0.0.1'
75
- - run: 'docker run --net=host -e CI --rm -v $(pwd):/work -v $(realpath ~/bundle):/bundle public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev sh -c "cd /work && bundle install --path /bundle && bundle exec rspec -fd -t integration_pebble"'
66
+ - run: 'bundle exec rspec -fd -t integration_pebble'
76
67
 
77
68
  docker-build:
78
69
  name: docker-build
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## v2.7.0 (2025-04-28)
2
+
3
+ ### Enhancements
4
+
5
+ - autorenew: gains new option `--remaining-life` (`-r`) to specify threshold in ratio of remaining lifetime to total lifetime, e.g. `1/3`, `50%`.
6
+
7
+ ### New behaviour
8
+
9
+ - autonenew: in addition to above, the default option is now adjusted to `--reamining-life 1/3` instead of `--days 7`. This conforms to the Let's Encrypt recommendation to renew certificates when its remaining lifetime is less than 1/3 of the total lifetime.
10
+ - docker: our provided Docker image now bundles rexml instead of nokogiri for aws-sdk-route53.
11
+
12
+
1
13
  ## v2.6.1 (2024-12-05)
2
14
 
3
15
  ### Fixes
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM sorah/ruby:3.2-dev as builder
1
+ FROM sorah/ruby:3.4-dev as builder
2
2
 
3
3
  #RUN apt-get update \
4
4
  # && apt-get install -y libmysqlclient-dev git-core \
@@ -12,7 +12,7 @@ RUN sed -i -e 's|Acmesmith::VERSION|"0.0.0"|g' -e '/^require.*acmesmith.version/
12
12
 
13
13
  RUN bundle install --path /gems --jobs 100 --without development
14
14
 
15
- FROM sorah/ruby:3.2
15
+ FROM sorah/ruby:3.4
16
16
 
17
17
  #RUN apt-get update \
18
18
  # && apt-get install -y libmysqlclient20 \
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in acmesmith.gemspec
4
4
  gemspec
5
5
 
6
- gem 'nokogiri'
6
+ gem 'rexml'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acmesmith (2.6.1)
4
+ acmesmith (2.7.0)
5
5
  acme-client (>= 2.0.7, < 3)
6
6
  aws-sdk-acm
7
7
  aws-sdk-route53
@@ -50,14 +50,10 @@ GEM
50
50
  jmespath (1.6.2)
51
51
  json (2.9.0)
52
52
  logger (1.6.2)
53
- mini_portile2 (2.8.8)
54
53
  net-http (0.6.0)
55
54
  uri
56
- nokogiri (1.16.8)
57
- mini_portile2 (~> 2.8.2)
58
- racc (~> 1.4)
59
- racc (1.8.1)
60
55
  rake (13.2.1)
56
+ rexml (3.4.1)
61
57
  rspec (3.13.0)
62
58
  rspec-core (~> 3.13.0)
63
59
  rspec-expectations (~> 3.13.0)
@@ -72,7 +68,7 @@ GEM
72
68
  rspec-support (~> 3.13.0)
73
69
  rspec-support (3.13.2)
74
70
  thor (1.3.2)
75
- uri (1.0.2)
71
+ uri (1.0.3)
76
72
 
77
73
  PLATFORMS
78
74
  ruby
@@ -80,8 +76,8 @@ PLATFORMS
80
76
  DEPENDENCIES
81
77
  acmesmith!
82
78
  bundler
83
- nokogiri
84
79
  rake
80
+ rexml
85
81
  rspec
86
82
 
87
83
  BUNDLED WITH
data/README.md CHANGED
@@ -67,7 +67,7 @@ $ acmesmith save-pkcs12 COMMON_NAME --output=PATH # Save certificate and p
67
67
  ```
68
68
 
69
69
  ```
70
- $ acmesmith autorenew [-d DAYS] # Renew certificates which being expired soon
70
+ $ acmesmith autorenew [-r RATIO] [-d DAYS] # Renew certificates which being expired soon. Default to -r 1/3
71
71
  ```
72
72
 
73
73
  ```
@@ -122,14 +122,23 @@ module Acmesmith
122
122
  SaveCertificateService.new(cert, **kwargs).perform!
123
123
  end
124
124
 
125
- def autorenew(days: 7, common_names: nil)
125
+ def autorenew(days: 30, remaining_life: nil, common_names: nil)
126
126
  (common_names || storage.list_certificates).each do |cn|
127
127
  puts "=> #{cn}"
128
128
  cert = storage.get_certificate(cn)
129
129
  not_after = cert.certificate.not_after.utc
130
130
 
131
- puts " Not valid after: #{not_after}"
132
- next unless (cert.certificate.not_after.utc - Time.now.utc) < (days.to_i * 86400)
131
+ lifetime = cert.certificate.not_after.utc - cert.certificate.not_before.utc
132
+ remaining = cert.certificate.not_after.utc - Time.now.utc
133
+ ratio = Rational(remaining,lifetime)
134
+
135
+ has_to_renew = false
136
+ has_to_renew ||= days && remaining < (days.to_i * 86400)
137
+ has_to_renew ||= remaining_life && ratio < remaining_life
138
+
139
+ puts " Not valid after: #{not_after} (lifetime=#{format_duration(lifetime+1)}, remaining=#{format_duration(remaining)}, #{"%0.2f" % (ratio.to_f*100)}%)"
140
+ next unless has_to_renew
141
+
133
142
  puts " * Renewing: CN=#{cert.common_name}, SANs=#{cert.sans.join(',')}"
134
143
  order_with_private_key(cert.common_name, *cert.sans, private_key: regenerate_private_key(cert.public_key))
135
144
  end
@@ -145,6 +154,22 @@ module Acmesmith
145
154
 
146
155
  private
147
156
 
157
+ # @param [Numeric] duration
158
+ def format_duration(duration)
159
+ raise ArgumentError if !duration.is_a?(Numeric) || duration < 0
160
+
161
+ # Calculate components using divmod
162
+ days, remainder = duration.divmod(86400)
163
+ hours, remainder = remainder.divmod(3600)
164
+ minutes, seconds = remainder.divmod(60)
165
+
166
+ # Create [value, unit] pairs, filter out zero values, format, and join
167
+ [[days, 'd'], [hours, 'h'], [minutes, 'm'], [seconds, 's']]
168
+ .select { |v,| v > 0 }
169
+ .map { |v, unit| "#{v.to_i}#{unit}" }
170
+ .join
171
+ end
172
+
148
173
 
149
174
  def config
150
175
  @config
@@ -143,9 +143,20 @@ module Acmesmith
143
143
  end
144
144
 
145
145
  desc "autorenew [COMMON_NAMES]", "request renewal of certificates which expires soon"
146
- method_option :days, type: :numeric, aliases: %w(-d), default: 7, desc: 'specify threshold in days to select certificates to renew'
146
+ method_option :days, type: :numeric, aliases: %w(-d), default: nil, desc: 'specify threshold in days to select certificates to renew'
147
+ method_option :remaining_life, type: :string, aliases: %w(-r), default: '1/3', desc: "Specify threshold based on remaining life. Accepts a percentage ('20%') or fraction ('1/3')"
147
148
  def autorenew(*common_names)
148
- client.autorenew(days: options[:days], common_names: common_names.empty? ? nil : common_names)
149
+ remaining_life = case options[:remaining_life]
150
+ when %r{\A\d+/\d+\z}
151
+ Rational(options[:remaining_life])
152
+ when %r{\A([\d.]+)%\z}
153
+ Rational($1.to_f, 100)
154
+ when nil
155
+ nil
156
+ else
157
+ raise ArgumentError, "invalid format for --remaining-life: it must be in '..%' or '../..'"
158
+ end
159
+ client.autorenew(days: options[:days], remaining_life: remaining_life, common_names: common_names.empty? ? nil : common_names)
149
160
  end
150
161
 
151
162
  desc "add-san COMMON_NAME [ADDITIONAL_SANS]", "request renewal of existing certificate with additional SANs"
@@ -1,3 +1,3 @@
1
1
  module Acmesmith
2
- VERSION = "2.6.1"
2
+ VERSION = "2.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acmesmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sorah Fukumori
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-04 00:00:00.000000000 Z
10
+ date: 2025-04-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: acme-client
@@ -200,7 +199,6 @@ homepage: https://github.com/sorah/acmesmith
200
199
  licenses:
201
200
  - MIT
202
201
  metadata: {}
203
- post_install_message:
204
202
  rdoc_options: []
205
203
  require_paths:
206
204
  - lib
@@ -215,8 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
213
  - !ruby/object:Gem::Version
216
214
  version: '0'
217
215
  requirements: []
218
- rubygems_version: 3.4.6
219
- signing_key:
216
+ rubygems_version: 3.6.2
220
217
  specification_version: 4
221
218
  summary: ACME client (Let's encrypt client) to manage certificate in multi server
222
219
  environment with cloud services (e.g. AWS)