Sha256: 3934f3654cacda3da3a1c90c86c4fe27e505b09114c4625336281ad6c6c5b314
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module Bullion module Models # ACMEv2 Challenge model class Challenge < ActiveRecord::Base after_initialize :init_values, unless: :persisted? belongs_to :authorization validates :acme_type, inclusion: { in: -> { Bullion.config.acme.challenge_clients.map(&:acme_type) } } validates :status, inclusion: { in: %w[invalid pending processing valid] } def identifier authorization.identifier["value"] end def init_values self.expires ||= Time.now + (60 * 60) self.token ||= SecureRandom.alphanumeric(48) end def thumbprint cipher = OpenSSL::Digest.new("SHA256") digest = cipher.digest(authorization.order.account.public_key.to_json) Base64.urlsafe_encode64(digest).delete("=") end 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bullion-0.6.0 | lib/bullion/models/challenge.rb |