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
# File 'lib/bullion/models/challenge.rb', line 31

def client
  challenge_class = Bullion.acme.challenge_clients.find { _1.acme_type == acme_type }

  unless challenge_class
    raise Bullion::Acme::Errors::UnsupportedChallengeType,
          "Challenge type '#{acme_type}' is not supported by Bullion."
  end

  challenge_class.new(self)
end

#identifierObject



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

def identifier
  authorization.identifier["value"]
end

#init_valuesObject



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

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

#thumbprintObject



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

def thumbprint
  cipher = OpenSSL::Digest.new("SHA256")
  digest = cipher.digest(lexicographically_ordered_public_key.to_json)
  Base64.urlsafe_encode64(digest).sub(/[\s=]*\z/, "")
end