Class: Acmesmith::Command
- Inherits:
-
Thor
- Object
- Thor
- Acmesmith::Command
- Defined in:
- lib/acmesmith/command.rb
Instance Method Summary collapse
- #add_san(name, *add_sans) ⇒ Object
- #authorize(*domains) ⇒ Object
- #autorenew(*names) ⇒ Object
- #current(name) ⇒ Object
- #list(name = nil) ⇒ Object
- #list_profiles ⇒ Object
- #new_account(contact) ⇒ Object
- #order(name, *sans) ⇒ Object
- #post_issue_hooks(name) ⇒ Object
- #register(contact) ⇒ Object
- #request(name, *sans) ⇒ Object
- #save(name) ⇒ Object
- #save_certificate(name) ⇒ Object
- #save_pkcs12(name) ⇒ Object
- #save_private_key(name) ⇒ Object
- #show_certificate(name) ⇒ Object
- #show_private_key(name) ⇒ Object
Instance Method Details
#add_san(name, *add_sans) ⇒ Object
176 177 178 |
# File 'lib/acmesmith/command.rb', line 176 def add_san(name, *add_sans) client.add_san(name, *add_sans) end |
#authorize(*domains) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/acmesmith/command.rb', line 20 def (*domains) warn "! WARNING: 'acmesmith authorize' is not available" warn "!" warn "! TL;DR: Go ahead; Just run 'acmesmith order'." warn "!" warn "! Pre-authorization have not implemented yet in acme-client.gem (v2) library." warn "! But, required domain authorizations will be performed automatically when ordering a certificate." warn "!" warn "! Pro Tips: Let's encrypt doesn't provide pre-authorization as of May 18, 2018." warn "!" # client.authorize(*domains) end |
#autorenew(*names) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/acmesmith/command.rb', line 161 def autorenew(*names) remaining_life = case [:remaining_life] when %r{\A\d+/\d+\z} Rational([:remaining_life]) when %r{\A([\d.]+)%\z} Rational($1.to_f, 100) when nil nil else raise ArgumentError, "invalid format for --remaining-life: it must be in '..%' or '../..'" end client.autorenew(days: [:days], remaining_life: remaining_life, names: names.empty? ? nil : names) end |
#current(name) ⇒ Object
80 81 82 |
# File 'lib/acmesmith/command.rb', line 80 def current(name) puts client.current(name) end |
#list(name = nil) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/acmesmith/command.rb', line 71 def list(name = nil) if name puts client.certificate_versions(name) else puts client.certificates_list end end |
#list_profiles ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/acmesmith/command.rb', line 58 def list_profiles profiles = client.list_profiles if profiles.nil? || profiles.empty? puts "No profiles available from this ACME directory" return end profiles.each do |name, description| puts "#{name}: #{description}" end end |
#new_account(contact) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/acmesmith/command.rb', line 12 def new_account(contact) puts "=> Creating an account ..." key = client.new_account(contact) puts "=> Public Key:" puts "\n#{key.private_key.public_key.to_pem}" end |
#order(name, *sans) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/acmesmith/command.rb', line 38 def order(name, *sans) cert = client.order( name, *sans, key_type: [:key_type], rsa_key_size: [:rsa_key_size], elliptic_curve: [:elliptic_curve], ) if [:show_certificate] puts cert.certificate.to_text puts cert.certificate.to_pem end end |
#post_issue_hooks(name) ⇒ Object
52 53 54 |
# File 'lib/acmesmith/command.rb', line 52 def post_issue_hooks(name) client.post_issue_hooks(name) end |
#register(contact) ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/acmesmith/command.rb', line 181 def register(contact) warn "!" warn "! DEPRECATION WARNING: Use 'acmesmith new-account' command" warn "! There is no user-facing breaking changes. It takes the same arguments with 'acmesmith register'." warn "!" warn "! This is due to change in semantics of ACME v2. ACME v2 defines 'new-account' instead of 'register' in v1." warn "!" new_account(contact) end |
#request(name, *sans) ⇒ Object
193 194 195 196 197 198 199 200 201 |
# File 'lib/acmesmith/command.rb', line 193 def request(name, *sans) warn "!" warn "! DEPRECATION WARNING: Use 'acmesmith order' command" warn "! There is no user-facing breaking changes. It takes the same arguments with 'acmesmith request'." warn "!" warn "! This is due to change in semantics of ACME v2. ACME v2 defines 'order' instead of 'request' in v1." warn "!" order(name, *sans) end |
#save(name) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/acmesmith/command.rb', line 127 def save(name) client.save( name, version: [:version], key_mode: [:key_mode], certificate_mode: [:certificate_mode], version_file: [:version_file], key_file: [:key_file], fullchain_file: [:fullchain_file], chain_file: [:chain_file], certificate_file: [:certificate_file], atomic: [:atomic], verbose: true, ) end |
#save_certificate(name) ⇒ Object
98 99 100 |
# File 'lib/acmesmith/command.rb', line 98 def save_certificate(name) client.save_certificate(name, version: [:version], mode: [:mode], output: [:output], type: [:type]) end |
#save_pkcs12(name) ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/acmesmith/command.rb', line 147 def save_pkcs12(name) print 'Passphrase: ' passphrase = $stdin.noecho { $stdin.gets }.chomp print "\nPassphrase (confirm): " passphrase2 = $stdin.noecho { $stdin.gets }.chomp puts raise ArgumentError, "Passphrase doesn't match" if passphrase != passphrase2 client.save_pkcs12(name, version: [:version], mode: [:mode], output: [:output], passphrase: passphrase) end |
#save_private_key(name) ⇒ Object
113 114 115 |
# File 'lib/acmesmith/command.rb', line 113 def save_private_key(name) client.save_private_key(name, version: [:version], mode: [:mode], output: [:output]) end |
#show_certificate(name) ⇒ Object
87 88 89 90 |
# File 'lib/acmesmith/command.rb', line 87 def show_certificate(name) certs = client.get_certificate(name, version: [:version], type: [:type]) puts certs end |
#show_private_key(name) ⇒ Object
104 105 106 |
# File 'lib/acmesmith/command.rb', line 104 def show_private_key(name) puts client.get_private_key(name, version: [:version]) end |