2019-05-16 05:32:25 -04:00
|
|
|
# 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
|
|
|
|
|
2019-06-06 14:55:31 -04:00
|
|
|
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-03-30 14:08:07 -04:00
|
|
|
def challenge_error
|
|
|
|
authorization.challenges.first&.error
|
|
|
|
end
|
|
|
|
|
2019-06-06 14:55:31 -04:00
|
|
|
delegate :url, :status, :expires, :certificate, to: :acme_order
|
2019-05-16 05:32:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :acme_order
|
2020-03-30 14:08:07 -04:00
|
|
|
|
|
|
|
def authorization
|
|
|
|
@acme_order.authorizations.first
|
|
|
|
end
|
2019-05-16 05:32:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|