amarillo 0.2.0 → 0.3.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/amarillo +16 -4
  3. data/lib/amarillo.rb +43 -4
  4. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b53b0e0803cc4bd89185cbfc67aeb3d468ab7f34988073d7c405f6e88f38e6fe
4
- data.tar.gz: ef2b8ec288bae0acd3924aa61ded5ccde2f9915bb15ec664316693641d4391e8
3
+ metadata.gz: 2dbdaceaf0eac001e1d7cb1ba63058ce2cee3e81be2c61d08378c3db7db562ae
4
+ data.tar.gz: b1afafa36c49e473a09bb56de32c354a668516e7fd71ec8770b38b681777c825
5
5
  SHA512:
6
- metadata.gz: 16eb56677f677b3b752de0af6e1b67dc6495b01a494e84e8c935ea19db84f3b16a2bf71cbc67893025388b4289b39d9ebf84f86b2e81b0abf0742c7707bd2e33
7
- data.tar.gz: 94af28ad358c6313fa4a43c00b0b31fc9f01d577556c90e8bf49c9396c06946c7d689abdd6fcd826b558fbcf74b3767b93c183055c2db7514510369033a8c1f6
6
+ metadata.gz: d19987aa6a9c84b92411fc5f5fa99102e9bd0f3abb8fcfb3dcacd8f28bc39a7806a28e932d7e39463680ca1281b701ad30b9a44e54c786918795f12d909d4e10
7
+ data.tar.gz: 2eef894b6c9ed756249684f31f2b4392ef2a79bd5c281858b64c9615f19bdabe91a46f43cf480fe9e9ff429c1cacc173f6d98b89916ffc21bc82f633906a675f
data/bin/amarillo CHANGED
@@ -29,7 +29,15 @@ options = {}
29
29
  OptionParser.new do |opts|
30
30
  opts.on("-i", "--initialize", "Initialize amarillo defaults") do |i|
31
31
  options[:initialize] = i
32
- end
32
+ end
33
+
34
+ opts.on("-l", "--list", "List certificates") do |l|
35
+ options[:list] = l
36
+ end
37
+
38
+ opts.on("-d", "--delete", "Delete certificate") do |d|
39
+ options[:delete] = d
40
+ end
33
41
 
34
42
  opts.on("-r", "--renew", "Renew certificates") do |r|
35
43
  options[:renew] = r
@@ -95,9 +103,9 @@ else
95
103
  email = options[:email]
96
104
  end
97
105
 
98
- if options[:name].nil? and options[:renew].nil? then
99
- puts "Usage: amarillo --name COMMONNAME [--zone ZONE] [--email EMAIL] [--amarillo-home AMARILLO_HOME]"
100
- exit -1
106
+ if options[:name].nil? and options[:renew].nil? and options[:list].nil? then
107
+ puts "Usage: amarillo --name COMMONNAME [--zone ZONE] [--email EMAIL] [--amarillo-home AMARILLO_HOME]"
108
+ exit -1
101
109
  else
102
110
  name = options[:name]
103
111
  end
@@ -112,6 +120,10 @@ y = Amarillo.new amarillo_home
112
120
 
113
121
  if options[:renew] then
114
122
  y.renewCertificates
123
+ elsif options[:list] then
124
+ y.listCertificates
125
+ elsif options[:delete] then
126
+ y.deleteCertificate name
115
127
  else
116
128
  y.requestCertificate zone, name, email, nil
117
129
  end
data/lib/amarillo.rb CHANGED
@@ -30,6 +30,7 @@ require 'aws-sdk-core' # Credentials
30
30
  require 'aws-sdk-route53' # Route 53
31
31
  require 'resolv' # DNS Resolvers
32
32
  require 'yaml' # YAML
33
+ require 'terminal-table' # Tablular output
33
34
 
34
35
  class Amarillo
35
36
 
@@ -184,15 +185,20 @@ class Amarillo
184
185
  csr = Acme::Client::CertificateRequest.new private_key: certPrivateKey,
185
186
  names: [commonName]
186
187
 
188
+ while order.status == 'processing'
189
+ sleep(1)
190
+ order.reload
191
+ end
192
+
193
+ @logger.info "Order status: #{order.status}"
194
+
187
195
  begin
188
196
  order.finalize(csr: csr)
189
197
  rescue
190
- @logger.error("ERROR")
198
+ @logger.error("Error finalizing certificate order")
191
199
  self.cleanup label, record_type, challengeValue
192
200
  end
193
201
 
194
- sleep(1) while order.status == 'processing'
195
-
196
202
  keyOutputPath = "#{@keyPath}/#{commonName}.key"
197
203
  certOutputPath = "#{@certificatePath}/#{commonName}.crt"
198
204
 
@@ -245,6 +251,39 @@ class Amarillo
245
251
 
246
252
  end
247
253
 
254
+ def listCertificates
255
+
256
+ rows = []
257
+
258
+ Dir["#{@configsPath}/*.yml"].each do |c|
259
+ config = YAML.load(File.read(c))
260
+
261
+ cn = config["commonName"]
262
+
263
+ certificatePath = "#{@certificatePath}/#{cn}.crt"
264
+ raw = File.read certificatePath
265
+ certificate = OpenSSL::X509::Certificate.new raw
266
+
267
+ rows << [config["commonName"], config["email"],
268
+ config["zone"], config["key_type"], certificate.not_after]
269
+
270
+ end
271
+
272
+ t = Terminal::Table.new :headings => ['commonName','email','zone','keytype','expiration'], :rows => rows
273
+ puts t
274
+ end
275
+
276
+ def deleteCertificate(commonName)
277
+ @logger.info "Deleting certificate #{commonName}"
278
+
279
+ certConfigFile = @configsPath + "/#{commonName}.yml"
280
+ certificatePath = @certificatePath + "/#{commonName}.crt"
281
+ keyPath = @keyPath + "/#{commonName}.key"
282
+
283
+ `rm -f #{certConfigFile} #{certificatePath} #{keyPath}`
284
+
285
+ end
286
+
248
287
  def renewCertificates
249
288
  t = Time.now
250
289
  @logger.info "Renewing certificates"
@@ -273,4 +312,4 @@ class Amarillo
273
312
  end
274
313
 
275
314
 
276
- require 'amarillo/environment'
315
+ require 'amarillo/environment'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amarillo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iAchieved.it LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-02 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acme-client
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.48'
69
+ - !ruby/object:Gem::Dependency
70
+ name: terminal-table
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
69
83
  description: A tool for managing Let's Encrypt dns-01 certificates
70
84
  email: joe@iachieved.it
71
85
  executables:
@@ -95,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  requirements: []
98
- rubygems_version: 3.2.3
112
+ rubygems_version: 3.3.3
99
113
  signing_key:
100
114
  specification_version: 4
101
115
  summary: Amarillo