Welcome to mirror list, hosted at ThFree Co, Russian Federation.

order.rb « lets_encrypt « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 656964f77f9bafc9aacb5d16d541c0c69f0ce487 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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

      def challenge_error
        authorization.challenges.first&.error
      end

      delegate :url, :status, :expires, :certificate, to: :acme_order

      private

      attr_reader :acme_order

      def authorization
        @acme_order.authorizations.first
      end
    end
  end
end