class Heroku::Command::Ssl

manage ssl certificates for an app

Public Instance Methods

add() click to toggle source

ssl:add PEM KEY

add an ssl certificate to an app

# File lib/heroku/command/ssl.rb, line 27
def add
  pem_file = args.shift
  key_file = args.shift
  fail "Usage: heroku ssl:add PEM KEY" unless pem_file && key_file
  raise CommandFailed, "Missing pem file." unless pem_file
  raise CommandFailed, "Missing key file." unless key_file
  raise CommandFailed, "Could not find pem in #{pem_file}"  unless File.exists?(pem_file)
  raise CommandFailed, "Could not find key in #{key_file}"  unless File.exists?(key_file)

  pem  = File.read(pem_file)
  key  = File.read(key_file)
  info = heroku.add_ssl(app, pem, key)
  display "Added certificate to #{info['domain']}, expiring at #{info['expires_at']}"
end
clear() click to toggle source

ssl:clear

remove all ssl certificates from an app

# File lib/heroku/command/ssl.rb, line 56
def clear
  heroku.clear_ssl(app)
  display "Cleared certificates for #{app}"
end
index() click to toggle source

ssl

list certificates for an app

# File lib/heroku/command/ssl.rb, line 13
def index
  api.get_domains(app).body.each do |domain|
    if cert = domain['cert']
      display "#{domain['domain']} has a SSL certificate registered to #{cert['subject']} which expires on #{format_date(cert['expires_at'])}"
    else
      display "#{domain['domain']} has no certificate"
    end
  end
end
remove() click to toggle source

ssl:remove DOMAIN

remove an ssl certificate from an app

# File lib/heroku/command/ssl.rb, line 46
def remove
  raise CommandFailed, "Missing domain. Usage:\nheroku ssl:remove <domain>" unless domain = args.shift
  heroku.remove_ssl(app, domain)
  display "Removed certificate from #{domain}"
end