Class: Bullion::Models::Challenge

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/bullion/models/challenge.rb

Overview

ACMEv2 Challenge model

Instance Method Summary collapse

Instance Method Details

#clientObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bullion/models/challenge.rb', line 24

def client
  case acme_type
  when "dns-01"
    DNS_CHALLENGE_CLIENT.new(self)
  when "http-01"
    HTTP_CHALLENGE_CLIENT.new(self)
  else
    raise Bullion::Acme::Errors::UnsupportedChallengeType,
          "Challenge type '#{acme_type}' is not supported by Bullion."
  end
end

#init_valuesObject



14
15
16
17
# File 'lib/bullion/models/challenge.rb', line 14

def init_values
  self.expires ||= Time.now + (60 * 60)
  self.token ||= SecureRandom.alphanumeric(48)
end

#thumbprintObject



19
20
21
22
# File 'lib/bullion/models/challenge.rb', line 19

def thumbprint
  cipher = OpenSSL::Digest.new("SHA256")
  cipher.hexdigest authorization.order..public_key.to_json
end