class Acmesmith::OrderingService
Attributes
acme[R]
challenge_responder_rules[R]
identifiers[R]
not_after[R]
not_before[R]
Public Class Methods
new(acme:, identifiers:, challenge_responder_rules:, not_before: nil, not_after: nil)
click to toggle source
@param acme [Acme::Client] ACME client @param identifiers [Array<String>] Array of domain names for a ordering certificate. The first item will be a common name. @param challenge_responder_rules
[Array<Acmesmith::Config::ChallengeResponderRule>] responders @param not_before
[Time] @param not_after
[Time]
# File lib/acmesmith/ordering_service.rb, line 13 def initialize(acme:, identifiers:, challenge_responder_rules:, not_before: nil, not_after: nil) @acme = acme @identifiers = identifiers @challenge_responder_rules = challenge_responder_rules @not_before = not_before @not_after = not_after end
Public Instance Methods
certificate()
click to toggle source
# File lib/acmesmith/ordering_service.rb, line 80 def certificate @certificate or raise NotCompleted, "not completed yet" end
common_name()
click to toggle source
@return [String]
# File lib/acmesmith/ordering_service.rb, line 90 def common_name identifiers.first end
csr()
click to toggle source
@return [Acme::Client::CertificateRequest]
# File lib/acmesmith/ordering_service.rb, line 100 def csr @csr ||= Acme::Client::CertificateRequest.new(subject: { common_name: common_name }, names: sans) end
finalize_order()
click to toggle source
# File lib/acmesmith/ordering_service.rb, line 60 def finalize_order puts puts "=> Finalizing the order" puts puts csr.csr.to_pem puts print " * Requesting..." order.finalize(csr: csr) puts" [ ok ]" end
order()
click to toggle source
@return Acme::Client::Resources::Order[]
# File lib/acmesmith/ordering_service.rb, line 85 def order @order or raise "BUG: order not yet generated" end
perform!()
click to toggle source
# File lib/acmesmith/ordering_service.rb, line 23 def perform! puts "=> Ordering a certificate for the following identifiers:" puts puts " * CN: #{common_name}" sans.each do |san| puts " * SAN: #{san}" end puts puts "=> Placing an order" @order = acme.new_order(identifiers: identifiers, not_before: not_before, not_after: not_after) puts " * URL: #{order.url}" ensure_authorization() finalize_order() wait_order_for_complete() @certificate = Certificate.by_issuance(order.certificate, csr) puts puts "=> Certificate issued" nil end
sans()
click to toggle source
@return [Array<String>]
# File lib/acmesmith/ordering_service.rb, line 95 def sans identifiers[1..-1] end
wait_order_for_complete()
click to toggle source
# File lib/acmesmith/ordering_service.rb, line 72 def wait_order_for_complete while %w(ready processing).include?(order.status) order.reload() puts " * Waiting for complete: status=#{order.status}" sleep 2 end end