Class: ApartmentAcmeClient::AcmeClient::RealClient
- Inherits:
-
Object
- Object
- ApartmentAcmeClient::AcmeClient::RealClient
- Defined in:
- lib/apartment_acme_client/acme_client/real_client.rb
Instance Attribute Summary collapse
-
#csr_private_key ⇒ Object
readonly
Returns the value of attribute csr_private_key.
Instance Method Summary collapse
- #authorize(domain:) ⇒ Object
-
#initialize(acme_client_private_key:, csr_private_key:) ⇒ RealClient
constructor
A new instance of RealClient.
- #new_order(identifiers:) ⇒ Object
- #register(email) ⇒ Object
-
#request_certificate(common_name:, names:, order:) ⇒ Object
Create a Certificate for our new set of domain names returns that certificate.
Constructor Details
#initialize(acme_client_private_key:, csr_private_key:) ⇒ RealClient
Returns a new instance of RealClient.
10 11 12 13 14 15 16 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 10 def initialize(acme_client_private_key:, csr_private_key:) @client = Acme::Client.new( private_key: acme_client_private_key, directory: server_directory ) @csr_private_key = csr_private_key end |
Instance Attribute Details
#csr_private_key ⇒ Object (readonly)
Returns the value of attribute csr_private_key.
8 9 10 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 8 def csr_private_key @csr_private_key end |
Instance Method Details
#authorize(domain:) ⇒ Object
26 27 28 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 26 def (domain:) @client.(domain: domain) end |
#new_order(identifiers:) ⇒ Object
30 31 32 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 30 def new_order(identifiers:) @client.new_order(identifiers: identifiers) end |
#register(email) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 18 def register(email) # If the private key is not known to the server, we need to register it for the first time. account = @client.new_account(contact: "mailto:#{email}", terms_of_service_agreed: true) Rollbar.info("New Let's Encrypt Account created with KID: #{account.kid}") true end |
#request_certificate(common_name:, names:, order:) ⇒ Object
Create a Certificate for our new set of domain names returns that certificate
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/apartment_acme_client/acme_client/real_client.rb', line 36 def request_certificate(common_name:, names:, order:) # We're going to need a certificate signing request. If not explicitly # specified, the first name listed becomes the common name. csr = Acme::Client::CertificateRequest.new(private_key: csr_private_key, common_name: common_name, names: names) order.finalize(csr: csr) while order.status == 'processing' sleep(1) order.reload end order.certificate end |