letsencrypt_http_challenge 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/LICENSE +22 -0
- data/README.md +109 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/letsencrypt_http_challenge/application.js +13 -0
- data/app/assets/stylesheets/letsencrypt_http_challenge/application.css +15 -0
- data/app/controllers/letsencrypt_http_challenge/application_controller.rb +27 -0
- data/app/helpers/letsencrypt_http_challenge/application_helper.rb +4 -0
- data/app/views/layouts/letsencrypt_http_challenge/application.html.erb +14 -0
- data/bin/rails +12 -0
- data/config/routes.rb +3 -0
- data/letsencrypt_http_challenge.gemspec +23 -0
- data/lib/letsencrypt_http_challenge/engine.rb +5 -0
- data/lib/letsencrypt_http_challenge/version.rb +3 -0
- data/lib/letsencrypt_http_challenge.rb +4 -0
- data/lib/tasks/letsencrypt_http_challenge_tasks.rake +87 -0
- data/test/controllers/application_controller_test.rb +27 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +30 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +508 -0
- data/test/dummy/log/test.log +243 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/letsencrypt_http_challenge_test.rb +7 -0
- data/test/test_helper.rb +25 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 82643283927b5bf83b10ddadd668c18b155de5e4
|
4
|
+
data.tar.gz: d495c3b3d4a47ce9d090e869cb628410ad2f130b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9496094f655598a83c293cc6bb451ea593f4b0667ef73f213450a4b3096b5e844f21d259bd04225bbfabd2ce5b5309680f46c41f8b6c2759247ad57c915e74f8
|
7
|
+
data.tar.gz: af8401752b96cdd643d03e185298da37182666895957266665b3196313bce4d641fe500ab05c011991a4c22f773715e77f5fd9525512ac9e7d0f2f8cfa0e4324
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in letsencrypt_http_challenge.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use a debugger
|
14
|
+
# gem 'byebug', group: [:development, :test]
|
15
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Luc Lussier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# letsencrypt_http_challenge
|
2
|
+
A Rails::Engine answering Let's Encrypt ACME - Simple HTTP - Identifier Validation Challenges on a twelve-factor app along with the rake task to automate the certificate generation.
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In you application, add this line to your Gemfile:
|
8
|
+
```ruby
|
9
|
+
gem 'letsencrypt_http_challenge'
|
10
|
+
```
|
11
|
+
|
12
|
+
Install the gem with bundler:
|
13
|
+
```bash
|
14
|
+
$ bundle install
|
15
|
+
```
|
16
|
+
Or manually with the gem command:
|
17
|
+
```bash
|
18
|
+
$ gem install letsencrypt_http_challenge
|
19
|
+
```
|
20
|
+
|
21
|
+
Mount the engine in your application's routes.rb file
|
22
|
+
```ruby
|
23
|
+
Rails.application.routes.draw do
|
24
|
+
mount LetsencryptHttpChallenge::Engine => "/" unless ENV['LE_HTTP_CHALLENGE_RESPONSE'].blank?
|
25
|
+
|
26
|
+
# Other routes...
|
27
|
+
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Run the interactive `generate_letsencrypt_cert` rake task from your local machine, setting the necessary environment variables:
|
35
|
+
```bash
|
36
|
+
$ LE_HTTP_CHALLENGE_CONTACT_EMAIL=admin@example.com LE_HTTP_CHALLENGE_CERTIFICATE_DOMAINS="www.example.com example.com" bundle exec rake generate_letsencrypt_cert
|
37
|
+
```
|
38
|
+
|
39
|
+
This will interact with the staging server. To obtain certificates from the production server, also add `LE_HTTP_CHALLENGE_ENDPOINT='https://acme-v01.api.letsencrypt.org/'` to your environment
|
40
|
+
|
41
|
+
When prompted by the script, update the LE_HTTP_CHALLENGE_RESPONSE variable on the web server and restart it. This could be further automated depending on the features of the web server hosting environment. The initial release require manual updates for each domain that needs to be verified.
|
42
|
+
|
43
|
+
A sample interaction could be as follow:
|
44
|
+
```bash
|
45
|
+
LE_HTTP_CHALLENGE_CONTACT_EMAIL=admin@example.com LE_HTTP_CHALLENGE_CERTIFICATE_DOMAINS="www.example.com example.com" bundle exec rake generate_letsencrypt_cert
|
46
|
+
Registering with Let's Encrypt service...
|
47
|
+
Success
|
48
|
+
Sending authorization request(s)...
|
49
|
+
|
50
|
+
Set
|
51
|
+
LE_HTTP_CHALLENGE_RESPONSE=6DOqR_BmMD02pYh-Rwpo3-1Dy-EauqbN_bFMbCypnsI.Iv478AtdWnuUCE6e-UfAJFN6y-F3YUTYG-skUvfYPJc
|
52
|
+
on your Rails web server and restart it.
|
53
|
+
|
54
|
+
You can test by pointing your browser to
|
55
|
+
www.example.com/.well-known/acme-challenge/6DOqR_BmMD02pYh-Rwpo3-1Dy-EauqbN_bFMbCypnsI
|
56
|
+
|
57
|
+
Looking good?
|
58
|
+
Press any key to continue.
|
59
|
+
Requesting verification...
|
60
|
+
|
61
|
+
Set
|
62
|
+
LE_HTTP_CHALLENGE_RESPONSE=JvWeOoR-NgyQINyR92QhtFPOL7txd8EHSx94Lh466p4.Iv478AtdWnuUCE6e-UfAJFN6y-F3YUTYG-skUvfYPJc
|
63
|
+
on your Rails web server and restart it.
|
64
|
+
|
65
|
+
You can test by pointing your browser to
|
66
|
+
example.com/.well-known/acme-challenge/JvWeOoR-NgyQINyR92QhtFPOL7txd8EHSx94Lh466p4
|
67
|
+
|
68
|
+
Looking good?
|
69
|
+
Press any key to continue.
|
70
|
+
Requesting verification...
|
71
|
+
|
72
|
+
Requesting the certificate...
|
73
|
+
Certificate saved
|
74
|
+
```
|
75
|
+
|
76
|
+
For a server hosted on Heroku:
|
77
|
+
```bash
|
78
|
+
# Set the variable manually from the command line or from their web based console
|
79
|
+
heroku config:set LE_HTTP_CHALLENGE_RESPONSE=JPizvzEPdRV4c4jRuNeFiLt0CCzL4aX-m4Ota1WYxh4.E_dQtIfQA9oIW2T7stzq9SgogpUQS2Ha2A4mxlCeAPk --app your_app_name
|
80
|
+
|
81
|
+
# Deleted it after the verification is done
|
82
|
+
heroku config:unset LE_HTTP_CHALLENGE_RESPONSE --app your_app_name
|
83
|
+
|
84
|
+
# Update an existing certificate
|
85
|
+
heroku certs:update fullchain.pem privkey.pem --app your_app_name
|
86
|
+
```
|
87
|
+
|
88
|
+
For more information about SSL on Heroku, please refer to their Dev Center article:
|
89
|
+
https://devcenter.heroku.com/articles/ssl-endpoint
|
90
|
+
|
91
|
+
Finally, store the certificate files created by the script `privkey.pem cert.pem chain.pem fullchain.pem` in a safe location.
|
92
|
+
|
93
|
+
|
94
|
+
## TODO
|
95
|
+
|
96
|
+
- Automate the deployment on Heroku and other hosting services
|
97
|
+
|
98
|
+
|
99
|
+
## Acknowledgements
|
100
|
+
|
101
|
+
LetsencryptHttpChallenge was inspired by:
|
102
|
+
|
103
|
+
lgromanowski/letsencrypt-plugin https://github.com/lgromanowski/letsencrypt-plugin
|
104
|
+
unixcharles/acme-client https://github.com/unixcharles/acme-client
|
105
|
+
|
106
|
+
|
107
|
+
## License
|
108
|
+
|
109
|
+
[MIT License](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'LetsencryptHttpChallenge'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module LetsencryptHttpChallenge
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
def index
|
5
|
+
challenge = params[:challenge].to_s
|
6
|
+
response = ENV['LE_HTTP_CHALLENGE_RESPONSE'].to_s
|
7
|
+
status = :ok
|
8
|
+
|
9
|
+
# https://letsencrypt.github.io/acme-spec/#rfc.section.7.1
|
10
|
+
|
11
|
+
# token (required, string): This value MUST have at least 128 bits of entropy
|
12
|
+
if challenge.length < 16
|
13
|
+
response = 'Challenge failed - The token must have at least 128 bits of entropy'
|
14
|
+
Rails.logger.error response
|
15
|
+
status = :bad_request
|
16
|
+
|
17
|
+
# its “token” field is equal to the “token” field in the challenge;
|
18
|
+
elsif response.match(challenge).nil?
|
19
|
+
response = 'Challenge failed - The token must match between the challenge and the response'
|
20
|
+
Rails.logger.error response
|
21
|
+
status = :bad_request
|
22
|
+
end
|
23
|
+
|
24
|
+
render plain: response, status: status
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>LetsencryptHttpChallenge</title>
|
5
|
+
<%= stylesheet_link_tag "letsencrypt_http_challenge/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "letsencrypt_http_challenge/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/letsencrypt_http_challenge/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "letsencrypt_http_challenge/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "letsencrypt_http_challenge"
|
9
|
+
s.version = LetsencryptHttpChallenge::VERSION
|
10
|
+
s.authors = ["Luc Lussier"]
|
11
|
+
s.email = ["luc.lussier@gmail.com"]
|
12
|
+
s.homepage = "https://github.com/datamolecule/letsencrypt_http_challenge"
|
13
|
+
s.summary = "Answer the Let's Encrypt ACME http challenge"
|
14
|
+
s.description = "A Rails engine that provides a response mechanism for Let's Encrypt ACME - Simple HTTP - Identifier Validation Challenges on 12 factor apps like those deployed on Heroku as well as the rake task to generate the certificate from your local machine."
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = Dir["{app,bin,config,lib}/**/*", "Gemfile", "LICENSE", "README.md", "Rakefile", "letsencrypt_http_challenge.gemspec"]
|
18
|
+
s.test_files = Dir["test/**/*"]
|
19
|
+
|
20
|
+
s.add_dependency "rails", "~> 4.1"
|
21
|
+
|
22
|
+
s.add_dependency "acme-client", "~> 0.2.2"
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Sample usage:
|
2
|
+
# LE_HTTP_CHALLENGE_CONTACT_EMAIL=admin@example.com LE_HTTP_CHALLENGE_CERTIFICATE_DOMAINS="www.example.com example.com" bundle exec rake generate_letsencrypt_cert
|
3
|
+
# Using the staging endpoint by default. Also set
|
4
|
+
# LE_HTTP_CHALLENGE_ENDPOINT='https://acme-v01.api.letsencrypt.org/'
|
5
|
+
# for production
|
6
|
+
|
7
|
+
# LE_HTTP_CHALLENGE_ENDPOINT - (Optional) The staging endpoint will be used unless defined.
|
8
|
+
# LE_HTTP_CHALLENGE_CONTACT_EMAIL - Domain contact email.
|
9
|
+
# LE_HTTP_CHALLENGE_CERTIFICATE_DOMAINS - The domains and sub-domains for which the certificate is requested.
|
10
|
+
# The first domain in the list will be the "Common Name" of the certificate.
|
11
|
+
|
12
|
+
# LE_HTTP_CHALLENGE_RESPONSE - The response to provide to the ACME challenge; Must be defined for the web server.
|
13
|
+
|
14
|
+
|
15
|
+
desc "Generate Let's Encrypt certificate with the http challenge"
|
16
|
+
task :generate_letsencrypt_cert do
|
17
|
+
|
18
|
+
require 'io/console'
|
19
|
+
require 'openssl'
|
20
|
+
require 'acme-client'
|
21
|
+
|
22
|
+
options = {
|
23
|
+
endpoint: ENV.fetch('LE_HTTP_CHALLENGE_ENDPOINT', 'https://acme-staging.api.letsencrypt.org/'),
|
24
|
+
contact_email: ENV.fetch('LE_HTTP_CHALLENGE_CONTACT_EMAIL'),
|
25
|
+
domains: ENV.fetch('LE_HTTP_CHALLENGE_CERTIFICATE_DOMAINS').split
|
26
|
+
}
|
27
|
+
|
28
|
+
def generate_cert(options)
|
29
|
+
client = Acme::Client.new(private_key: OpenSSL::PKey::RSA.new(2048), endpoint: options[:endpoint])
|
30
|
+
|
31
|
+
puts 'Registering with Let\'s Encrypt service...'
|
32
|
+
registration = client.register(contact: "mailto:#{options[:contact_email]}")
|
33
|
+
if registration.agree_terms
|
34
|
+
puts 'Success'
|
35
|
+
else
|
36
|
+
puts 'Failed'
|
37
|
+
return
|
38
|
+
end
|
39
|
+
|
40
|
+
puts 'Sending authorization request(s)...'
|
41
|
+
options[:domains].each do |domain|
|
42
|
+
authorization = client.authorize(domain: domain)
|
43
|
+
challenge = authorization.http01
|
44
|
+
|
45
|
+
puts ''
|
46
|
+
puts 'Set'
|
47
|
+
puts "LE_HTTP_CHALLENGE_RESPONSE=#{challenge.file_content}"
|
48
|
+
puts 'on your Rails web server and restart it.'
|
49
|
+
puts ''
|
50
|
+
puts 'You can test by pointing your browser to'
|
51
|
+
puts "#{domain}/#{challenge.filename}"
|
52
|
+
puts ''
|
53
|
+
|
54
|
+
puts 'Looking good?'
|
55
|
+
press_any_key
|
56
|
+
|
57
|
+
puts 'Requesting verification...'
|
58
|
+
challenge.request_verification
|
59
|
+
sleep(1) while 'pending' == challenge.verify_status
|
60
|
+
|
61
|
+
puts "Validation failed for #{domain}" unless 'valid' == challenge.verify_status
|
62
|
+
end
|
63
|
+
|
64
|
+
puts ''
|
65
|
+
puts 'Requesting the certificate...'
|
66
|
+
csr = Acme::CertificateRequest.new(names: options[:domains])
|
67
|
+
certificate = client.new_certificate(csr)
|
68
|
+
|
69
|
+
if certificate.nil?
|
70
|
+
puts 'Failed to obtain certificate'
|
71
|
+
else
|
72
|
+
File.write('privkey.pem', certificate.request.private_key.to_pem)
|
73
|
+
File.write('cert.pem', certificate.to_pem)
|
74
|
+
File.write('chain.pem', certificate.chain_to_pem)
|
75
|
+
File.write('fullchain.pem', certificate.fullchain_to_pem)
|
76
|
+
puts 'Certificate saved'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def press_any_key
|
81
|
+
puts 'Press any key to continue.'
|
82
|
+
STDIN.getch
|
83
|
+
end
|
84
|
+
|
85
|
+
generate_cert(options)
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module LetsencryptHttpChallenge
|
4
|
+
class ApplicationControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@routes = LetsencryptHttpChallenge::Engine.routes
|
7
|
+
end
|
8
|
+
|
9
|
+
test "matching challenge token returns the challenge response" do
|
10
|
+
get :index, challenge: '58u1GLEGwgSbK-3LnTYUDwZySN3FmTxE4CuqAf8IpAU'
|
11
|
+
assert_response :success
|
12
|
+
assert_match('58u1GLEGwgSbK-3LnTYUDwZySN3FmTxE4CuqAf8IpAU.VDnmZ7G7W4pPpHL_rTLA9SUPSN0qTwe876q2C2gpLLs', response.body)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "token must match" do
|
16
|
+
get :index, challenge: '58u1GLEGwgSbK-3LnTYUDwZySN3FmTxE4CuqAf8IpAU_wrong_token'
|
17
|
+
assert_response :bad_request
|
18
|
+
assert_match('token must match between', response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "token must be longer than 128 bits" do
|
22
|
+
get :index, challenge: '58u1GLEG'
|
23
|
+
assert_response :bad_request
|
24
|
+
assert_match('token must have at least 128 bits', response.body)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# require 'rails/all'
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
# require 'action_mailer/railtie'
|
6
|
+
# require 'sprockets/railtie'
|
7
|
+
require 'rails/test_unit/railtie'
|
8
|
+
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
require 'letsencrypt_http_challenge'
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
19
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
20
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
21
|
+
|
22
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
23
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
24
|
+
# config.i18n.default_locale = :de
|
25
|
+
|
26
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
27
|
+
# config.active_record.raise_in_transactional_callbacks = true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: db/production.sqlite3
|