acme-pki 0.2.2 → 0.2.3

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/bin/letsencrypt +78 -75
  4. data/lib/acme/pki.rb +10 -4
  5. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1b3bb99647eef45519719558500aff9ce5325234ce231c0b5f7579bedfb7cc6
4
- data.tar.gz: 423f0acb7ce5aba3def12e8efa3abd2a07057f9b1e1bc95edca8dcbc9c1691ba
3
+ metadata.gz: 7599cb3c3ceecf3e1ce1fb057339106937398c2ce6887a9f16442de981d351af
4
+ data.tar.gz: c81b97fc9132d5442185cfc4ea011b93175e8568dfeb582c0f1e7834ba3b2942
5
5
  SHA512:
6
- metadata.gz: 91fa143f71c8efbafab9271e972590867fb0d861bda0a7158a9842db7bf37cadcedb789e0bc3c54655719812ef0669c69c1f9d35600165e1938c6b2158a97937
7
- data.tar.gz: e59060943b8256352be03b51ec8d4ed1440dceed48aad0382601c288f0b7857ad02cef52e1b050ed3e1c71433c35c8d20a789624bfa08ff24802d4135fb1f47b
6
+ metadata.gz: ade350294c8dc14ee322120e342697d5f98b0d66cc98b611e908fda4502e011b196ca25ba0b0b548579800db9865600898cc77f3cf2a035c1ed17e36f5acfcd5
7
+ data.tar.gz: beeb43ea7b6d2e2f2551bc114edcc69349f7bcd85d66f54a872dce086bc062bbd56b77ae619b5344404a786c7b7e05a5ed13b9efd585bddff4f6c897321b8aa9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acme-pki (0.2.1)
4
+ acme-pki (0.2.3)
5
5
  acme-client (~> 2.0)
6
6
  colorize (~> 0.8)
7
7
  faraday_middleware (~> 0.13)
@@ -22,79 +22,82 @@ EOTEXT
22
22
  ARGV << 'help' if ARGV.length.zero?
23
23
 
24
24
  case ARGV.shift
25
- when /help|-[hH]|--help/
26
- puts HELP
27
- exit 0
28
- when 'register'
29
- OptionParser.new do |opts|
30
- opts.banner = "Usage: #{File.basename __FILE__} register <email>"
31
- end.parse!
32
- if ARGV.empty?
33
- puts "An email address is required !"
34
- exit -1
35
- end
36
- pki.register ARGV.first
37
- when 'key'
38
- options = OpenStruct.new type: Acme::PKI::DEFAULT_KEY_TYPE
39
- OptionParser.new do |opts|
40
- opts.banner = "Usage: #{File.basename __FILE__} key <domain> [options]"
41
- opts.on('-r [KEYSIZE]', '--rsa [KEYSIZE]', 'RSA key, key size') { |k| options.type = [:rsa, k.to_i] }
42
- opts.on('-e [CURVE]', '--ecc [CURVE]', 'ECC key, curve') { |k| options.type = [:ecc, k] }
43
- end.parse!
44
- if ARGV.empty?
45
- puts 'A domain is required !'
46
- exit -1
47
- end
48
- pki.generate_key ARGV.first, type: options.type
49
- when 'csr'
50
- options = OpenStruct.new domains: []
51
- OptionParser.new do |opts|
52
- opts.banner = "Usage: #{File.basename __FILE__} csr <domain> [options]"
53
- opts.on('-k [KEYFILE]', '--key [KEYFILE]', 'Key file') { |k| options.key = k }
54
- opts.on('-d [DOMAIN]', '--domain [DOMAIN]', 'Domain') { |d| options.domains << d }
55
- end.parse!
56
- if ARGV.empty?
57
- puts 'A domain is required !'
58
- exit -1
59
- end
60
- pki.generate_csr ARGV.first, key: options.key, domains: options.domains
61
- when 'crt'
62
- options = OpenStruct.new
63
- OptionParser.new do |opts|
64
- opts.banner = "Usage: #{File.basename __FILE__} crt <domain> [options]"
65
- opts.on('-c [CSR]', '--csr [CSR]', 'CSR file') { |c| options.csr = c }
66
- end.parse!
67
- if ARGV.empty?
68
- puts 'A domain is required !'
69
- exit -1
70
- end
71
- pki.generate_crt ARGV.first, csr: options.csr
72
- when 'renew'
73
- options = OpenStruct.new
74
- OptionParser.new do |opts|
75
- opts.banner = "Usage: #{File.basename __FILE__} renew <domain> [options]"
76
- opts.on('-c [CSR]', '--csr [CSR]', 'CSR file') { |c| options.csr = c }
77
- end.parse!
78
- if ARGV.empty?
79
- puts 'A domain is required !'
80
- exit -1
81
- end
82
- exit pki.renew(ARGV.first, csr: options.csr) ? 0 : 1
83
- when 'info'
84
- type = :key
85
- OptionParser.new do |opts|
86
- opts.banner = "Usage: #{File.basename __FILE__} info <domain> [options]"
87
- opts.on('-k', '--key', 'Key information') { type = :key }
88
- opts.on('-c', '--crt', 'Certificate information') { type = :crt }
89
- end.parse!
90
- if ARGV.empty?
91
- puts 'A domain is required !'
92
- exit -1
93
- end
94
- case type
95
- when :key
96
- pki.key_info pki.key ARGV.first
97
- when :crt
98
- pki.chain_info pki.crt ARGV.first
99
- end
25
+ when /help|-[hH]|--help/
26
+ puts HELP
27
+ exit 0
28
+ when 'register'
29
+ OptionParser.new do |opts|
30
+ opts.banner = "Usage: #{File.basename __FILE__} register <email>"
31
+ end.parse!
32
+ if ARGV.empty?
33
+ puts "An email address is required !"
34
+ exit -1
35
+ end
36
+ pki.register ARGV.first
37
+ when 'key'
38
+ options = OpenStruct.new type: Acme::PKI::DEFAULT_KEY_TYPE
39
+ OptionParser.new do |opts|
40
+ opts.banner = "Usage: #{File.basename __FILE__} key <domain> [options]"
41
+ opts.on('-r [KEYSIZE]', '--rsa [KEYSIZE]', 'RSA key, key size') { |k| options.type = [:rsa, k.to_i] }
42
+ opts.on('-e [CURVE]', '--ecc [CURVE]', 'ECC key, curve') { |k| options.type = [:ecc, k] }
43
+ end.parse!
44
+ if ARGV.empty?
45
+ puts 'A domain is required !'
46
+ exit -1
47
+ end
48
+ pki.generate_key ARGV.first, type: options.type
49
+ when 'csr'
50
+ options = OpenStruct.new domains: [], adds: [], removes: []
51
+ OptionParser.new do |opts|
52
+ opts.banner = "Usage: #{File.basename __FILE__} csr <domain> [options]"
53
+ opts.on('-k [KEYFILE]', '--key [KEYFILE]', 'Key file') { |k| options.key = k }
54
+ opts.on('-d [DOMAIN]', '--domain [DOMAIN]', 'Domain') { |d| options.domains << d }
55
+ opts.on('-a [DOMAIN]', '--add [DOMAIN]', 'Add domain') { |d| options.adds << d }
56
+ opts.on('-r [DOMAIN]', '--remove [DOMAIN]', 'Remove domain') { |d| options.removes << d }
57
+ end.parse!
58
+ if ARGV.empty?
59
+ puts 'A domain is required !'
60
+ exit -1
61
+ end
62
+ pki.generate_csr ARGV.first, key: options.key, domains: options.domains,
63
+ add: options.adds, remove: options.removes
64
+ when 'crt'
65
+ options = OpenStruct.new
66
+ OptionParser.new do |opts|
67
+ opts.banner = "Usage: #{File.basename __FILE__} crt <domain> [options]"
68
+ opts.on('-c [CSR]', '--csr [CSR]', 'CSR file') { |c| options.csr = c }
69
+ end.parse!
70
+ if ARGV.empty?
71
+ puts 'A domain is required !'
72
+ exit -1
73
+ end
74
+ pki.generate_crt ARGV.first, csr: options.csr
75
+ when 'renew'
76
+ options = OpenStruct.new
77
+ OptionParser.new do |opts|
78
+ opts.banner = "Usage: #{File.basename __FILE__} renew <domain> [options]"
79
+ opts.on('-c [CSR]', '--csr [CSR]', 'CSR file') { |c| options.csr = c }
80
+ end.parse!
81
+ if ARGV.empty?
82
+ puts 'A domain is required !'
83
+ exit -1
84
+ end
85
+ exit pki.renew(ARGV.first, csr: options.csr) ? 0 : 1
86
+ when 'info'
87
+ type = :key
88
+ OptionParser.new do |opts|
89
+ opts.banner = "Usage: #{File.basename __FILE__} info <domain> [options]"
90
+ opts.on('-k', '--key', 'Key information') { type = :key }
91
+ opts.on('-c', '--crt', 'Certificate information') { type = :crt }
92
+ end.parse!
93
+ if ARGV.empty?
94
+ puts 'A domain is required !'
95
+ exit -1
96
+ end
97
+ case type
98
+ when :key
99
+ pki.key_info pki.key ARGV.first
100
+ when :crt
101
+ pki.chain_info pki.crt ARGV.first
102
+ end
100
103
  end
@@ -89,14 +89,20 @@ module Acme
89
89
  [key_file, key]
90
90
  end
91
91
 
92
- def generate_csr(csr, domains: [], key: nil)
93
- key = csr unless key
94
- domains = [csr, *domains].collect { |d| SimpleIDN.to_ascii d }
92
+ def generate_csr(csr, domains: [], add: [], remove: [], key: nil)
93
+ key = csr unless key
95
94
  csr_file = self.csr csr
96
95
  key_file = self.key key
97
-
98
96
  self.generate_key key unless File.exist? key_file
99
97
 
98
+ domains = if add.empty? && remove.empty?
99
+ [csr, *domains]
100
+ else
101
+ tmp = OpenSSL::X509::Request.new File.read csr_file
102
+ domains = self.domains tmp
103
+ domains - remove + add
104
+ end.collect { |d| SimpleIDN.to_ascii d }
105
+
100
106
  self.process "Generating CSR for #{domains.join ', '} with key #{key_file} into #{csr_file}" do
101
107
  key_file = open(key_file, 'r') { |f| OpenSSL::PKey.read f }
102
108
  csr = OpenSSL::X509::Request.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acme-pki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aeris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,7 +131,7 @@ homepage: https://github.com/aeris/acme-pki/
131
131
  licenses:
132
132
  - AGPL-3.0+
133
133
  metadata: {}
134
- post_install_message:
134
+ post_install_message:
135
135
  rdoc_options: []
136
136
  require_paths:
137
137
  - lib
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubygems_version: 3.0.3
150
- signing_key:
150
+ signing_key:
151
151
  specification_version: 4
152
152
  summary: Ruby client for Let's Encrypt
153
153
  test_files: []