class KingslyCertbot::KingslyClient
Public Class Methods
get_cert_bundle(kingsly_server_host:, kingsly_server_port:, top_level_domain:, sub_domain:, kingsly_http_read_timeout: 120, kingsly_http_open_timeout: 5)
click to toggle source
# File lib/kingsly_certbot/kingsly_client.rb, line 9 def self.get_cert_bundle(kingsly_server_host:, kingsly_server_port:, top_level_domain:, sub_domain:, kingsly_http_read_timeout: 120, kingsly_http_open_timeout: 5) body = { 'top_level_domain' => top_level_domain, 'sub_domain' => sub_domain } uri = URI.parse("http://#{kingsly_server_host}:#{kingsly_server_port}/v1/cert_bundles") http = Net::HTTP.new(uri.host, uri.port) http.read_timeout = kingsly_http_read_timeout http.open_timeout = kingsly_http_open_timeout headers = {} headers['Content-Type'] = 'application/json' resp = http.start do |http_request| http_request.post(uri.path, JSON.dump(body), headers) end raise 'Authentication failure with kingsly, Please check your authentication configuration' if resp.code == '401' body = JSON.parse(resp.body) CertBundle.new(top_level_domain, sub_domain, body['private_key'], body['full_chain']) end