Class: Acmesmith::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/acmesmith/command.rb

Instance Method Summary collapse

Instance Method Details

#add_san(common_name, *add_sans) ⇒ Object



144
145
146
# File 'lib/acmesmith/command.rb', line 144

def add_san(common_name, *add_sans)
  client.add_san(common_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 authorize(*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(*common_names) ⇒ Object



139
140
141
# File 'lib/acmesmith/command.rb', line 139

def autorenew(*common_names)
  client.autorenew(days: options[:days], common_names: common_names.empty? ? nil : common_names)
end

#current(common_name) ⇒ Object



59
60
61
# File 'lib/acmesmith/command.rb', line 59

def current(common_name)
  puts client.current(common_name)
end

#list(common_name = nil) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/acmesmith/command.rb', line 50

def list(common_name = nil)
  if common_name
    puts client.certificate_versions(common_name)
  else
    puts client.certificates_list
  end
end

#new_account(contact) ⇒ Object



12
13
14
15
16
17
# File 'lib/acmesmith/command.rb', line 12

def (contact)
  puts "=> Creating an account ..."
  key = client.(contact)
  puts "=> Public Key:"
  puts "\n#{key.private_key.public_key.to_pem}"
end

#order(common_name, *sans) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/acmesmith/command.rb', line 35

def order(common_name, *sans)
  cert = client.order(common_name, *sans)
  if options[:show_certificate]
    puts cert.certificate.to_text
    puts cert.certificate.to_pem
  end
end

#post_issue_hooks(common_name) ⇒ Object



44
45
46
# File 'lib/acmesmith/command.rb', line 44

def post_issue_hooks(common_name)
  client.post_issue_hooks(common_name)
end

#register(contact) ⇒ Object



149
150
151
152
153
154
155
156
157
# File 'lib/acmesmith/command.rb', line 149

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 "!"
  (contact)
end

#request(common_name, *sans) ⇒ Object



161
162
163
164
165
166
167
168
169
# File 'lib/acmesmith/command.rb', line 161

def request(common_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(common_name, *sans)
end

#save(common_name) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/acmesmith/command.rb', line 106

def save(common_name)
  client.save(
    common_name,
    version: options[:version],
    key_mode: options[:key_mode],
    certificate_mode: options[:certificate_mode],
    version_file: options[:version_file],
    key_file: options[:key_file],
    fullchain_file: options[:fullchain_file],
    chain_file: options[:chain_file],
    certificate_file: options[:certificate_file],
    atomic: options[:atomic],
    verbose: true,
  )
end

#save_certificate(common_name) ⇒ Object



77
78
79
# File 'lib/acmesmith/command.rb', line 77

def save_certificate(common_name)
  client.save_certificate(common_name, version: options[:version], mode: options[:mode], output: options[:output], type: options[:type])
end

#save_pkcs12(common_name) ⇒ Object

Raises:

  • (ArgumentError)


126
127
128
129
130
131
132
133
134
135
# File 'lib/acmesmith/command.rb', line 126

def save_pkcs12(common_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(common_name, version: options[:version], mode: options[:mode], output: options[:output], passphrase: passphrase)
end

#save_private_key(common_name) ⇒ Object



92
93
94
# File 'lib/acmesmith/command.rb', line 92

def save_private_key(common_name)
  client.save_private_key(common_name, version: options[:version], mode: options[:mode], output: options[:output])
end

#show_certificate(common_name) ⇒ Object



66
67
68
69
# File 'lib/acmesmith/command.rb', line 66

def show_certificate(common_name)
  certs = client.get_certificate(common_name, version: options[:version], type: options[:type])
  puts certs
end

#show_private_key(common_name) ⇒ Object



83
84
85
# File 'lib/acmesmith/command.rb', line 83

def show_private_key(common_name)
  puts client.get_private_key(common_name, version: options[:version])
end