debian-mirror-gitlab/lib/gitlab/lets_encrypt/order.rb

40 lines
848 B
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
module Gitlab
module LetsEncrypt
class Order
def initialize(acme_order)
@acme_order = acme_order
end
def new_challenge
challenge = authorization.http
::Gitlab::LetsEncrypt::Challenge.new(challenge)
end
def request_certificate(domain:, private_key:)
csr = ::Acme::Client::CertificateRequest.new(
private_key: OpenSSL::PKey.read(private_key),
subject: { common_name: domain }
)
acme_order.finalize(csr: csr)
end
2020-04-22 19:07:51 +05:30
def challenge_error
authorization.challenges.first&.error
end
2019-09-04 21:01:54 +05:30
delegate :url, :status, :expires, :certificate, to: :acme_order
private
attr_reader :acme_order
2020-04-22 19:07:51 +05:30
def authorization
@acme_order.authorizations.first
end
2019-09-04 21:01:54 +05:30
end
end
end