Sha256: 9628e928bbed3dd20c37c33caaa97f5a6bfee0c99ea5dfef2355d89369c4df6f

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module Letsencrypt
  class << self
    attr_accessor :configuration
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield(configuration) if block_given?
  end

  def self.challenge_configured?
    configuration.acme_challenge_filename && 
      configuration.acme_challenge_filename.start_with?(".well-known/") &&
      configuration.acme_challenge_file_content
  end

  def self.registered?
    configuration.acme_private_key && configuration.acme_key_id
  end

  class Configuration
    attr_accessor :heroku_token, :heroku_app, :acme_email, :acme_domain,
      :acme_directory, :ssl_type, :acme_terms_agreed
    
    # Not settable by user; part of the gem's behaviour.
    attr_reader :acme_challenge_filename, :acme_challenge_file_content,
      :acme_private_key, :acme_key_id

    def initialize
      @heroku_token = ENV["HEROKU_TOKEN"]
      @heroku_app = ENV["HEROKU_APP"]
      @acme_email = ENV["ACME_EMAIL"]
      @acme_domain = ENV["ACME_DOMAIN"]
      @acme_directory = 'https://acme-v02.api.letsencrypt.org/directory'
      @acme_terms_agreed = ENV["ACME_TERMS_AGREED"]
      @ssl_type = ENV["SSL_TYPE"] || 'sni'

      @acme_challenge_filename = ENV["ACME_CHALLENGE_FILENAME"]
      @acme_challenge_file_content = ENV["ACME_CHALLENGE_FILE_CONTENT"]

      @acme_private_key = ENV["ACME_PRIVATE_KEY"]
      @acme_key_id = ENV["ACME_KEY_ID"]
    end

    def valid?
      heroku_token && heroku_app && acme_email && acme_terms_agreed
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
letsencrypt-rails-heroku-2.0.3 lib/letsencrypt-rails-heroku/letsencrypt.rb
letsencrypt-rails-heroku-2.0.2 lib/letsencrypt-rails-heroku/letsencrypt.rb
letsencrypt-rails-heroku-2.0.1 lib/letsencrypt-rails-heroku/letsencrypt.rb
letsencrypt-rails-heroku-2.0.0 lib/letsencrypt-rails-heroku/letsencrypt.rb