Class: Bullion::ChallengeClients::HTTP

Inherits:
Bullion::ChallengeClient show all
Defined in:
lib/bullion/challenge_clients/http.rb

Overview

ACME HTTP01 Challenge Client

Direct Known Subclasses

RSpec::ChallengeClients::HTTP

Constant Summary

Constants inherited from Bullion::ChallengeClient

Bullion::ChallengeClient::ChallengeClientMetric

Instance Attribute Summary

Attributes inherited from Bullion::ChallengeClient

#challenge

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bullion::ChallengeClient

#attempt, #identifier, #initialize

Constructor Details

This class inherits a constructor from Bullion::ChallengeClient

Class Method Details

.acme_typeObject



8
# File 'lib/bullion/challenge_clients/http.rb', line 8

def self.acme_type = "http-01"

Instance Method Details

#challenge_urlObject



23
24
25
# File 'lib/bullion/challenge_clients/http.rb', line 23

def challenge_url
  "http://#{identifier}/.well-known/acme-challenge/#{challenge.token}"
end

#performObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bullion/challenge_clients/http.rb', line 11

def perform
  response = begin
    retrieve_body(challenge_url)
  rescue SocketError
    LOGGER.debug "Failed to connect to #{challenge_url}"
    ""
  end

  token, thumbprint = response.split(".")
  token == challenge.token && thumbprint == challenge.thumbprint
end

#retrieve_body(url) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/bullion/challenge_clients/http.rb', line 27

def retrieve_body(url)
  HTTParty.get(
    url,
    verify: false,
    headers: { "User-Agent" => "Bullion/#{Bullion::VERSION}" }
  ).body
end

#typeObject



9
# File 'lib/bullion/challenge_clients/http.rb', line 9

def type = "HTTP01"