class Letsencrypt::Cli::App

Public Instance Methods

__print_version() click to toggle source
# File lib/letsencrypt/cli/app.rb, line 105
def __print_version
  puts Letsencrypt::Cli::VERSION
end
authorize(*domains) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 38
def authorize(*domains)
  rc = 0
  order = wrapper.create_order(domains)
  order.authorizations.each do |authorization|
    if !wrapper.authorize(authorization)
      rc = 1
    end
  end
  if rc != 0
    exit rc
  end
end
authorize_all() click to toggle source
# File lib/letsencrypt/cli/app.rb, line 30
def authorize_all
  lines = Dir[ File.join(@options[:webserver_dir], "*")].map{|file| File.read(file).lines.grep(/^\s*server_name/) }.flatten
  domains = lines.flatten.map{|i| i.strip.split(/[; ]/).drop(1) }.flatten.reject{|i| i.length < 3 }.uniq
  authorize(*domains)
end
cert(*domains) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 58
def cert(*domains)
  if domains.length == 0
    wrapper.log "no domains given", :fatal
    exit 1
  end
  wrapper.cert(domains)
end
check(path) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 68
def check(path)
  if !wrapper.check_certificate(path)
    exit 1
  end
end
manage(*domains) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 87
def manage(*domains)
  key_dir = File.join(@options[:key_directory], @options[:sub_directory] || domains.first)
  FileUtils.mkdir_p(key_dir)
  @options = @options.merge(
    :private_key_path  => File.join(key_dir, 'key.pem'),
    :fullchain_path    => File.join(key_dir, 'fullchain.pem'),
    :certificate_path  => File.join(key_dir, 'cert.pem'),
    :chain_path        => File.join(key_dir, 'chain.pem'),
  )
  if wrapper.check_certificate(@options[:certificate_path])
    exit 2
  end
  authorize(*domains)
  cert(*domains)
end
register(email) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 14
def register(email)
  if email.nil? || email == ""
    wrapper.log "no E-Mail specified!", :fatal
    exit 1
  end
  if !email[/.*@.*/]
    wrapper.log "not an email", :fatal
    exit 1
  end
  registration = wrapper.client.new_account(contact: "mailto:" + email, terms_of_service_agreed: true)
  wrapper.log "Account created, Terms accepted"
end
revoke(path) click to toggle source
# File lib/letsencrypt/cli/app.rb, line 75
def revoke(path)
  if !wrapper.revoke_certificate(path)
    exit 1
  end
end

Private Instance Methods

wrapper() click to toggle source
# File lib/letsencrypt/cli/app.rb, line 111
def wrapper
  @wrapper ||= AcmeWrapper.new(options)
end