Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed domain wildcard issues #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/letsencrypt-rails-heroku/letsencrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ def self.configure
end

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

class Configuration
attr_accessor :heroku_token, :heroku_app, :acme_email, :acme_domain, :acme_endpoint
attr_accessor :heroku_token, :heroku_app, :heroku_app_domain, :acme_email, :acme_domain, :acme_endpoint

# Not settable by user; part of the gem's behaviour.
attr_reader :acme_challenge_filename, :acme_challenge_file_content

def initialize
@heroku_token = ENV["HEROKU_TOKEN"]
@heroku_app = ENV["HEROKU_APP"]
@heroku_app_domain = ENV["HEROKU_APP_DOMAIN"]
@acme_email = ENV["ACME_EMAIL"]
@acme_domain = ENV["ACME_DOMAIN"]
@acme_endpoint = ENV["ACME_ENDPOINT"] || 'https://acme-v01.api.letsencrypt.org/'
Expand Down
15 changes: 13 additions & 2 deletions lib/tasks/letsencrypt.rake
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,19 @@ namespace :letsencrypt do
print "Testing filename works (to bring up app)..."

# Get the domain name from Heroku
hostname = heroku.domain.list(heroku_app).first['hostname']

if Letsencrypt.configuration.heroku_app_domain
puts "Using hostname from HEROKU_APP_DOMAIN environment variable"
hostname = Letsencrypt.configuration.heroku_app_domain
else
puts "Trying to guess hostname from registered app domains"
heroku_domains = heroku.domain.list(heroku_app)
heroku_domain = heroku_domains.find { |heroku_domain_i| !heroku_domain_i["hostname"].start_with?("*.") }
raise "Couldn't find domain on Heroku that wasn't a wildcard: #{heroku_domains}" unless heroku_domain
hostname = heroku_domain["hostname"]
end

puts "Using hostname: #{hostname}"

# Wait at least a little bit, otherwise the first request will almost always fail.
sleep(2)

Expand Down