diff options
author | elijah <elijah@riseup.net> | 2016-08-30 23:27:39 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2016-08-30 23:27:39 -0700 |
commit | cd809a6b69790b48344abfaa294edd8c4d4c7231 (patch) | |
tree | 80effc5c22179bd678a5d5d3873c81153fc8dbcf /vendor/acme-client/lib/acme/client/resources/challenges/base.rb | |
parent | d324b3e4af6869414ee928c6f507093791c10c1c (diff) |
added acme-client gem
Diffstat (limited to 'vendor/acme-client/lib/acme/client/resources/challenges/base.rb')
-rw-r--r-- | vendor/acme-client/lib/acme/client/resources/challenges/base.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/acme-client/lib/acme/client/resources/challenges/base.rb b/vendor/acme-client/lib/acme/client/resources/challenges/base.rb new file mode 100644 index 0000000..c78c74e --- /dev/null +++ b/vendor/acme-client/lib/acme/client/resources/challenges/base.rb @@ -0,0 +1,43 @@ +class Acme::Client::Resources::Challenges::Base + attr_reader :authorization, :status, :uri, :token, :error + + def initialize(authorization) + @authorization = authorization + end + + def client + authorization.client + end + + def verify_status + authorization.verify_status + + status + end + + def request_verification + response = client.connection.post(@uri, resource: 'challenge', type: challenge_type, keyAuthorization: authorization_key) + response.success? + end + + def assign_attributes(attributes) + @status = attributes.fetch('status', 'pending') + @uri = attributes.fetch('uri') + @token = attributes.fetch('token') + @error = attributes['error'] + end + + private + + def challenge_type + self.class::CHALLENGE_TYPE + end + + def authorization_key + "#{token}.#{crypto.thumbprint}" + end + + def crypto + @crypto ||= Acme::Client::Crypto.new(client.private_key) + end +end |