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



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bullion/models/challenge.rb', line 31

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

#identifierObject



17
18
19
# File 'lib/bullion/models/challenge.rb', line 17

def identifier
  authorization.identifier["value"]
end

#init_valuesObject



21
22
23
24
# File 'lib/bullion/models/challenge.rb', line 21

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

#thumbprintObject



26
27
28
29
# File 'lib/bullion/models/challenge.rb', line 26

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