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

Allow gem to work with MongoDB on Heroku #51

Open
simonv3 opened this issue Sep 24, 2016 · 4 comments
Open

Allow gem to work with MongoDB on Heroku #51

simonv3 opened this issue Sep 24, 2016 · 4 comments

Comments

@simonv3
Copy link

simonv3 commented Sep 24, 2016

I'm under the impression that this gem won't work with MongoDB on Heroku: #39 because Heroku is a read-only file system and this either requires the challenge directory or ActiveRecord?

Related because I can't create files on Heroku - (or unrelated, I'm not sure?) I can't figure out how to make the private key available on Heroku without checking it into the source code. I don't think checking it into the source code is the right way to go, but we're an open source app, so...

@lgromanowski
Copy link
Owner

lgromanowski commented Sep 26, 2016

Hi,
on Heroku you should use DB as a challenge storage (challenge_dir_name should be commented in config file) and after that please run rake letsencrypt_plugin task on heroku - it should connect with letsencrypt servers and print certificates on console.

// EDIT: I forgot that MongoDB gem don't use ActiveRecord - so, at this moment, this gem won't work with MongoDB on Heroku (patches are welcome)

@simonv3
Copy link
Author

simonv3 commented Sep 26, 2016

If you outline how and where to look and make this work and what kind of tests to write for this I would gladly write a PR. (If you don't have time for that it will just take me longer to do so :P)

@lgromanowski
Copy link
Owner

Code for challenge is placed in Challenge Model: https://github.com/lgromanowski/letsencrypt-plugin/blob/master/app/models/letsencrypt_plugin/challenge.rb:

module LetsencryptPlugin
  # if the project doesn't use ActiveRecord, we assume the challenge will
  # be stored in the filesystem
  if LetsencryptPlugin.config.challenge_dir_name.blank? && defined?(ActiveRecord::Base) == 'constant' && ActiveRecord::Base.class == Class
    class Challenge < ActiveRecord::Base
    end
  else
    class Challenge
      attr_accessor :response

      def initialize
        full_challenge_dir = File.join(Rails.root, LetsencryptPlugin.config.challenge_dir_name, 'challenge')
        @response = IO.read(full_challenge_dir)
      end
    end
  end
end

Place which should be changed is Challenge::initialize() method in "else" branch - at this moment that code tries to read challenge from a file.

@simonv3
Copy link
Author

simonv3 commented Sep 26, 2016

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants