Class: Acme::Resources::Challenges::SimpleHttp

Inherits:
Object
  • Object
show all
Defined in:
lib/acme/resources/challenges/simple_http.rb

Constant Summary collapse

CONTENT_TYPE =
'application/jose+json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, attributes) ⇒ SimpleHttp

Returns a new instance of SimpleHttp.



7
8
9
10
# File 'lib/acme/resources/challenges/simple_http.rb', line 7

def initialize(client, attributes)
  @client = client
  assign_attributes(attributes)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/acme/resources/challenges/simple_http.rb', line 4

def error
  @error
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/acme/resources/challenges/simple_http.rb', line 4

def status
  @status
end

#tlsObject

Returns the value of attribute tls.



5
6
7
# File 'lib/acme/resources/challenges/simple_http.rb', line 5

def tls
  @tls
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/acme/resources/challenges/simple_http.rb', line 4

def token
  @token
end

#uriObject (readonly)

Returns the value of attribute uri.



4
5
6
# File 'lib/acme/resources/challenges/simple_http.rb', line 4

def uri
  @uri
end

Instance Method Details

#content_typeObject



12
13
14
# File 'lib/acme/resources/challenges/simple_http.rb', line 12

def content_type
  CONTENT_TYPE
end

#file_contentObject



16
17
18
19
# File 'lib/acme/resources/challenges/simple_http.rb', line 16

def file_content
  message = { 'type' => 'simpleHttp', 'token' => token, 'tls' => tls }
  crypto.generate_signed_jws(header: {}, payload: message)
end

#filenameObject



21
22
23
# File 'lib/acme/resources/challenges/simple_http.rb', line 21

def filename
  ".well-known/acme-challenge/#{token}"
end

#request_verificationObject



25
26
27
28
# File 'lib/acme/resources/challenges/simple_http.rb', line 25

def request_verification
  response = @client.connection.post(@uri, { resource: 'challenge', type: 'simpleHttp', tls: tls })
  response.success?
end

#verify_statusObject



30
31
32
33
34
35
36
# File 'lib/acme/resources/challenges/simple_http.rb', line 30

def verify_status
  response = @client.connection.get(@uri)

  assign_attributes(response.body)
  @error = response.body['error']
  status
end