Class: Encryptbot::Heroku

Inherits:
Object
  • Object
show all
Defined in:
lib/encryptbot/heroku.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeroku

Returns a new instance of Heroku.



8
9
10
11
# File 'lib/encryptbot/heroku.rb', line 8

def initialize
  @app = Encryptbot.configuration.heroku_app
  @token = Encryptbot.configuration.heroku_token
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



6
7
8
# File 'lib/encryptbot/heroku.rb', line 6

def app
  @app
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/encryptbot/heroku.rb', line 6

def token
  @token
end

Instance Method Details

#add_certificate(certificate, private_key) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/encryptbot/heroku.rb', line 13

def add_certificate(certificate, private_key)
  # list certificate to check if one already exists
  sni_endpoints = platform.sni_endpoint.list(@app)

  begin
    if sni_endpoints.any?
      # update existing ssl certificate
      platform.sni_endpoint.update(@app, sni_endpoints[0]["name"], {
        certificate_chain: certificate,
        private_key: private_key
      })
    else
      # add new ssl certificate
      platform.sni_endpoint.create(@app, {
        certificate_chain: certificate,
        private_key: private_key
      })
    end
  rescue => e
    raise Encryptbot::Error::HerokuCertificateError, e
  end
end