Sha256: 3c15d8746a5ed297da587ace4cb4575c133c0e7abe9d8f49b7ee2cdf505e6135

Contents?: true

Size: 922 Bytes

Versions: 3

Compression:

Stored size: 922 Bytes

Contents

module LetsencryptHttpChallenge
  class ApplicationController < ActionController::Base

    def index
      challenge = params[:challenge].to_s
      response = ENV['LE_HTTP_CHALLENGE_RESPONSE'].to_s
      status = :ok

      # https://letsencrypt.github.io/acme-spec/#rfc.section.7.1

      # token (required, string): This value MUST have at least 128 bits of entropy
      if challenge.length < 16
        response = 'Challenge failed - The token must have at least 128 bits of entropy'
        Rails.logger.error response
        status = :bad_request

      # its “token” field is equal to the “token” field in the challenge;
      elsif response.match(challenge).nil?
        response = 'Challenge failed - The token must match between the challenge and the response'
        Rails.logger.error response
        status = :bad_request
      end

      render plain: response, status: status
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
letsencrypt_http_challenge-0.0.3 app/controllers/letsencrypt_http_challenge/application_controller.rb
letsencrypt_http_challenge-0.0.2 app/controllers/letsencrypt_http_challenge/application_controller.rb
letsencrypt_http_challenge-0.0.1 app/controllers/letsencrypt_http_challenge/application_controller.rb