Class: Acmesmith::ChallengeResponders::PebbleChalltestsrvDns

Inherits:
Base
  • Object
show all
Defined in:
lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#applicable?, #cap_respond_all?, #cleanup_all, #respond_all

Constructor Details

#initialize(url: 'http://localhost:8055') ⇒ PebbleChalltestsrvDns

Returns a new instance of PebbleChalltestsrvDns.



14
15
16
17
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 14

def initialize(url: 'http://localhost:8055')
  warn_test
  @url = URI.parse(url)
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



19
20
21
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 19

def url
  @url
end

Instance Method Details

#cleanup(domain, challenge) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 33

def cleanup(domain, challenge)
  warn_test

  Net::HTTP.post(
    URI.join(url,"/clear-txt"),
    {
      host: "#{challenge.record_name}.#{domain}.",
    }.to_json,
  ).value
end

#respond(domain, challenge) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 21

def respond(domain, challenge)
  warn_test

  Net::HTTP.post(
    URI.join(url,"/set-txt"),
    {
      host: "#{challenge.record_name}.#{domain}.",
      value: challenge.record_content,
    }.to_json,
  ).value
end

#support?(type) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 9

def support?(type)
  # Acme::Client::Resources::Challenges::DNS01
  type == 'dns-01'
end

#warn_testObject



44
45
46
47
48
49
50
# File 'lib/acmesmith/challenge_responders/pebble_challtestsrv_dns.rb', line 44

def warn_test
  unless ENV['CI']
    $stderr.puts '!!!!!!!!! WARNING WARNING WARNING !!!!!!!!!'
    $stderr.puts '!!!! pebble-challtestsrv command is for TEST USAGE ONLY. It is trivially insecure, offering no authentication. Only use pebble-challtestsrv in a controlled test environment.'
    $stderr.puts '!!!! https://github.com/letsencrypt/pebble/blob/master/cmd/pebble-challtestsrv/README.md'
  end
end