heroku_dnsimple_cert 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.env.example +6 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +49 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +66 -0
- data/LICENSE +20 -0
- data/README.md +76 -0
- data/Rakefile +6 -0
- data/bin/autospec +16 -0
- data/bin/build +6 -0
- data/bin/bundle-audit +16 -0
- data/bin/console +7 -0
- data/bin/quality +7 -0
- data/bin/rake +17 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/setup +11 -0
- data/exe/heroku-dnsimple-cert +4 -0
- data/heroku_dnsimple_cert.gemspec +35 -0
- data/lib/.keep +1 -0
- data/lib/heroku_dnsimple_cert/cli.rb +70 -0
- data/lib/heroku_dnsimple_cert/dnsimple_certificate.rb +43 -0
- data/lib/heroku_dnsimple_cert/heroku_certificate.rb +33 -0
- data/lib/heroku_dnsimple_cert/heroku_sni.rb +23 -0
- data/lib/heroku_dnsimple_cert/version.rb +3 -0
- data/lib/heroku_dnsimple_cert.rb +10 -0
- metadata +200 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e4d8af92b86bebef8babdd6c18af8496b69dc00
|
4
|
+
data.tar.gz: 10003228dbd0da219cb3ba5073fe5cf11ac8d9bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb8fb434a6fc3af99516b66cd90007f4a051e6936f23af2e615917feea7c372b74252ef9a2bec1e534bd88c96f82916a6d2c78e0825d126d6168d3dbd078c490
|
7
|
+
data.tar.gz: 816669a9c4c522386a7b90e664cce0fb1445ec761f21abe12a8bdd0161eee49469667907c610371c898c0476e803965d97bbb6a55da2c156964bd5fa54374bb8
|
data/.env.example
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- bin/**/*
|
7
|
+
- vendor/**/*
|
8
|
+
|
9
|
+
Rails:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Description: 'Document classes and non-namespace modules.'
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/MethodCalledOnDoEndBlock:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Style/CollectionMethods:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Style/SymbolArray:
|
23
|
+
Description: 'Use %i or %I for arrays of symbols.'
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Style/StringLiterals:
|
27
|
+
EnforcedStyle: double_quotes
|
28
|
+
|
29
|
+
Metrics/LineLength:
|
30
|
+
Description: 'Limit lines to 120 characters.'
|
31
|
+
Max: 120
|
32
|
+
|
33
|
+
Lint/EndAlignment:
|
34
|
+
AlignWith: variable
|
35
|
+
SupportedStyles:
|
36
|
+
- keyword
|
37
|
+
- variable
|
38
|
+
|
39
|
+
Style/AlignParameters:
|
40
|
+
EnforcedStyle: with_fixed_indentation
|
41
|
+
SupportedStyles:
|
42
|
+
- with_first_parameter
|
43
|
+
- with_fixed_indentation
|
44
|
+
|
45
|
+
Style/MultilineMethodCallIndentation:
|
46
|
+
EnforcedStyle: indented
|
47
|
+
|
48
|
+
Style/FrozenStringLiteralComment:
|
49
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
heroku_dnsimple_cert (0.1.0)
|
5
|
+
dnsimple
|
6
|
+
dotenv
|
7
|
+
httparty
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ast (2.3.0)
|
14
|
+
bundler-audit (0.5.0)
|
15
|
+
bundler (~> 1.2)
|
16
|
+
thor (~> 0.18)
|
17
|
+
diff-lcs (1.2.5)
|
18
|
+
dnsimple (4.0.0)
|
19
|
+
httparty
|
20
|
+
dotenv (2.1.1)
|
21
|
+
httparty (0.14.0)
|
22
|
+
multi_xml (>= 0.5.2)
|
23
|
+
multi_xml (0.5.5)
|
24
|
+
parser (2.3.3.1)
|
25
|
+
ast (~> 2.2)
|
26
|
+
powerpack (0.1.1)
|
27
|
+
rainbow (2.1.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
rspec (3.4.0)
|
30
|
+
rspec-core (~> 3.4.0)
|
31
|
+
rspec-expectations (~> 3.4.0)
|
32
|
+
rspec-mocks (~> 3.4.0)
|
33
|
+
rspec-core (3.4.4)
|
34
|
+
rspec-support (~> 3.4.0)
|
35
|
+
rspec-expectations (3.4.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.4.0)
|
38
|
+
rspec-mocks (3.4.1)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.4.0)
|
41
|
+
rspec-support (3.4.1)
|
42
|
+
rubocop (0.46.0)
|
43
|
+
parser (>= 2.3.1.1, < 3.0)
|
44
|
+
powerpack (~> 0.1)
|
45
|
+
rainbow (>= 1.99.1, < 3.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
48
|
+
rubocop-rspec (1.8.0)
|
49
|
+
rubocop (>= 0.42.0)
|
50
|
+
ruby-progressbar (1.8.1)
|
51
|
+
thor (0.19.4)
|
52
|
+
unicode-display_width (1.1.2)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler-audit
|
59
|
+
heroku_dnsimple_cert!
|
60
|
+
rake (~> 10.0)
|
61
|
+
rspec (~> 3.4)
|
62
|
+
rubocop
|
63
|
+
rubocop-rspec
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.13.6
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Flatstack
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Upload Certificate from DNSimple to Heroku
|
2
|
+
|
3
|
+
This gem provides `heroku-dnsimple-cert` executable script to upload SSL certificate from DNSimple to Heroku application.
|
4
|
+
|
5
|
+
## What it does
|
6
|
+
|
7
|
+
* Fetch certificate from DNSimple via API
|
8
|
+
* Add or update certificate on Heroku via API
|
9
|
+
|
10
|
+
## How to prepare
|
11
|
+
|
12
|
+
Issue certificate on DNSimple for the first time and enable auto-renew:
|
13
|
+
https://support.dnsimple.com/articles/ordering-lets-encrypt-certificate/
|
14
|
+
|
15
|
+
Change your DNS for domain on your app `www.yourdomainname.com.herokudns.com`:
|
16
|
+
https://devcenter.heroku.com/articles/ssl#change-your-dns-for-all-domains-on-your-app
|
17
|
+
|
18
|
+
Generate Heroku auth token:
|
19
|
+
```bash
|
20
|
+
heroku plugins:install heroku-cli-oauth
|
21
|
+
heroku authorizations:create -d "letsencrypt-heroku"
|
22
|
+
```
|
23
|
+
|
24
|
+
Generate DNSimple auth token:
|
25
|
+
https://support.dnsimple.com/articles/api-access-token/
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
When certificate will be issued on DNSimple you need to run script to setup it to the Heroku application:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
heroku-dnsimple-cert update \
|
33
|
+
--dnsimple-account-id=DNSIMPLE_ACCOUNT_ID \
|
34
|
+
--dnsimple-common-name=DNSIMPLE_COMMON_NAME \
|
35
|
+
--dnsimple-domain=DNSIMPLE_DOMAIN \
|
36
|
+
--dnsimple-token=DNSIMPLE_TOKEN \
|
37
|
+
--heroku-app=HEROKU_APP \
|
38
|
+
--heroku-token=HEROKU_TOKEN
|
39
|
+
```
|
40
|
+
|
41
|
+
You can configure these environment variables in `.env` or whatever you use,
|
42
|
+
so that `heroku-dnsimple-cert` will use them by default:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
DNSIMPLE_TOKEN=
|
46
|
+
DNSIMPLE_ACCOUNT_ID=
|
47
|
+
DNSIMPLE_DOMAIN=
|
48
|
+
DNSIMPLE_COMMON_NAME=
|
49
|
+
HEROKU_TOKEN=
|
50
|
+
HEROKU_APP=
|
51
|
+
```
|
52
|
+
|
53
|
+
At this point, you can verify that your application is serving your certificate by running:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
openssl s_client -connect <dns target>:443 -servername <your domain>
|
57
|
+
# e.g. openssl s_client -connect www.example.com.herokudns.com:443 -servername www.example.com
|
58
|
+
```
|
59
|
+
|
60
|
+
To enable certificate renew install script using Heroku Daily Scheduler.
|
61
|
+
|
62
|
+
## Develop
|
63
|
+
|
64
|
+
* `bin/build` checks your specs and runs quality tools
|
65
|
+
* `bin/quality` based on [RuboCop](https://github.com/bbatsov/rubocop)
|
66
|
+
* `.rubocop.yml` describes active checks
|
67
|
+
|
68
|
+
|
69
|
+
## Credits
|
70
|
+
|
71
|
+
Ruby Base is maintained by [Timur Vafin](http://github.com/timurvafin).
|
72
|
+
It was written by [Flatstack](http://www.flatstack.com) with the help of our
|
73
|
+
[contributors](http://github.com/fs/ruby-base/contributors).
|
74
|
+
|
75
|
+
|
76
|
+
[<img src="http://www.flatstack.com/logo.svg" width="100"/>](http://www.flatstack.com)
|
data/Rakefile
ADDED
data/bin/autospec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'autospec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'autospec')
|
data/bin/build
ADDED
data/bin/bundle-audit
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'bundle-audit' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('bundler-audit', 'bundle-audit')
|
data/bin/console
ADDED
data/bin/quality
ADDED
data/bin/rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/rubocop
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rubocop' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rubocop', 'rubocop')
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "heroku_dnsimple_cert/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heroku_dnsimple_cert"
|
8
|
+
spec.version = HerokuDnsimpleCert::VERSION
|
9
|
+
spec.authors = ["Timur Vafin"]
|
10
|
+
spec.email = ["timur.vafin@flatstack.com"]
|
11
|
+
|
12
|
+
spec.summary = "Upload SSL cert from DNSimple to Heroku."
|
13
|
+
spec.description = "Upload SSL cert from DNSimple to Heroku."
|
14
|
+
spec.homepage = "https://github.com/fs/heroku-dnsimple-cert"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "dnsimple"
|
26
|
+
spec.add_dependency "dotenv"
|
27
|
+
spec.add_dependency "httparty"
|
28
|
+
spec.add_dependency "thor"
|
29
|
+
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
32
|
+
spec.add_development_dependency "bundler-audit"
|
33
|
+
spec.add_development_dependency "rubocop"
|
34
|
+
spec.add_development_dependency "rubocop-rspec"
|
35
|
+
end
|
data/lib/.keep
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
Dotenv.load
|
4
|
+
|
5
|
+
module HerokuDnsimpleCert
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
OPTIONS = %w(dnsimple_token dnsimple_account_id dnsimple_domain dnsimple_common_name heroku_token heroku_app).freeze
|
10
|
+
|
11
|
+
OPTIONS.each do |option|
|
12
|
+
method_option(option, type: :string, default: ENV[option.upcase], required: true)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc :update, "Create or update Heroku certificate from DNSimple"
|
16
|
+
|
17
|
+
# rubocop:disable Metrics/AbcSize
|
18
|
+
# rubocop:disable Metrics/MethodLength
|
19
|
+
def update
|
20
|
+
say "Fetching certificate chain from DNSimple for #{options['dnsimple_common_name']} ...", :green
|
21
|
+
dnsimple_certificate.certificate_chain
|
22
|
+
|
23
|
+
say "Fetching private key from DNSimple for #{options['dnsimple_common_name']}. ..", :green
|
24
|
+
dnsimple_certificate.private_key
|
25
|
+
|
26
|
+
say "Fetching certificates from Heroku app #{options['heroku_app']} ...", :green
|
27
|
+
heroku_certificate.certificates
|
28
|
+
|
29
|
+
if heroku_certificate.certificates.any?
|
30
|
+
say "Updating existing certificate on Heroku app #{options['heroku_app']} ...", :green
|
31
|
+
heroku_certificate.update
|
32
|
+
else
|
33
|
+
say "Adding new certificate on Heroku app #{options['heroku_app']} ...", :green
|
34
|
+
heroku_certificate.create
|
35
|
+
end
|
36
|
+
|
37
|
+
say "Done!", :green
|
38
|
+
rescue => e
|
39
|
+
say "Error adding certificate ...", :red
|
40
|
+
say " Response: #{e}", :red
|
41
|
+
|
42
|
+
abort
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def dnsimple_certificate
|
48
|
+
@dnsimple_certificate ||= DnsimpleCertificate.new(
|
49
|
+
token: options["dnsimple_token"],
|
50
|
+
account_id: options["dnsimple_account_id"],
|
51
|
+
domain: options["dnsimple_domain"],
|
52
|
+
common_name: options["dnsimple_common_name"]
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def heroku_certificate
|
57
|
+
@heroku_certificate ||= HerokuCertificate.new(
|
58
|
+
token: options["heroku_token"],
|
59
|
+
app: options["heroku_app"],
|
60
|
+
certificate_chain: dnsimple_certificate.certificate_chain,
|
61
|
+
private_key: dnsimple_certificate.private_key
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def say(message = "", color = nil)
|
66
|
+
color = nil unless $stdout.tty?
|
67
|
+
super(message.to_s, color)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "dnsimple"
|
2
|
+
|
3
|
+
module HerokuDnsimpleCert
|
4
|
+
class DnsimpleCertificate
|
5
|
+
attr_reader :client, :account_id, :domain, :common_name
|
6
|
+
|
7
|
+
def initialize(token:, account_id:, domain:, common_name:, client: nil)
|
8
|
+
@client = client || Dnsimple::Client.new(access_token: token)
|
9
|
+
@account_id = account_id.to_i
|
10
|
+
@domain = domain
|
11
|
+
@common_name = common_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def certificate_chain
|
15
|
+
@certificate_key ||= begin
|
16
|
+
cert = client.certificates
|
17
|
+
.download_certificate(account_id, domain, certificate.id).data
|
18
|
+
|
19
|
+
[cert.server, cert.root, cert.chain].join("\n")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def private_key
|
24
|
+
@certificate_private_key ||= client.certificates
|
25
|
+
.certificate_private_key(account_id, domain, certificate.id)
|
26
|
+
.data.private_key
|
27
|
+
end
|
28
|
+
|
29
|
+
def certificate
|
30
|
+
@certificate ||= client
|
31
|
+
.certificates.certificates(account_id, domain)
|
32
|
+
.data.select { |certificate| certificate_for_common_name?(certificate) }
|
33
|
+
.first
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def certificate_for_common_name?(certificate)
|
39
|
+
certificate.state == "issued" &&
|
40
|
+
certificate.common_name == common_name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module HerokuDnsimpleCert
|
2
|
+
class HerokuCertificate
|
3
|
+
attr_reader :client, :app, :certificate_chain, :private_key
|
4
|
+
|
5
|
+
def initialize(token:, app:, certificate_chain:, private_key:, client: nil)
|
6
|
+
@client = client || HerokuSni.new(token, app)
|
7
|
+
@certificate_chain = certificate_chain
|
8
|
+
@private_key = private_key
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def certificates
|
13
|
+
@certificates ||= client.list
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
client.update(certificates[0]["name"], create_or_update_options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
client.create(create_or_update_options)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def create_or_update_options
|
27
|
+
{
|
28
|
+
certificate_chain: certificate_chain,
|
29
|
+
private_key: private_key
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class HerokuSni
|
2
|
+
include HTTParty
|
3
|
+
|
4
|
+
headers "Accept" => "application/vnd.heroku+json; version=3"
|
5
|
+
raise_on [422, 500]
|
6
|
+
|
7
|
+
def initialize(token, app_id)
|
8
|
+
self.class.base_uri "https://api.heroku.com/apps/#{app_id}/sni-endpoints"
|
9
|
+
self.class.headers "Authorization" => "Bearer #{token}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def list
|
13
|
+
self.class.get ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(options)
|
17
|
+
self.class.post "", body: options
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(name, options)
|
21
|
+
self.class.patch "/#{name}", body: options
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "dotenv"
|
2
|
+
|
3
|
+
require "heroku_dnsimple_cert/version"
|
4
|
+
require "heroku_dnsimple_cert/cli"
|
5
|
+
require "heroku_dnsimple_cert/dnsimple_certificate"
|
6
|
+
require "heroku_dnsimple_cert/heroku_sni"
|
7
|
+
require "heroku_dnsimple_cert/heroku_certificate"
|
8
|
+
|
9
|
+
module HerokuDnsimpleCert
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_dnsimple_cert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timur Vafin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dnsimple
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler-audit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Upload SSL cert from DNSimple to Heroku.
|
140
|
+
email:
|
141
|
+
- timur.vafin@flatstack.com
|
142
|
+
executables:
|
143
|
+
- heroku-dnsimple-cert
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".env.example"
|
148
|
+
- ".gitignore"
|
149
|
+
- ".rspec"
|
150
|
+
- ".rubocop.yml"
|
151
|
+
- ".ruby-version"
|
152
|
+
- ".travis.yml"
|
153
|
+
- Gemfile
|
154
|
+
- Gemfile.lock
|
155
|
+
- LICENSE
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/autospec
|
159
|
+
- bin/build
|
160
|
+
- bin/bundle-audit
|
161
|
+
- bin/console
|
162
|
+
- bin/quality
|
163
|
+
- bin/rake
|
164
|
+
- bin/rspec
|
165
|
+
- bin/rubocop
|
166
|
+
- bin/setup
|
167
|
+
- exe/heroku-dnsimple-cert
|
168
|
+
- heroku_dnsimple_cert.gemspec
|
169
|
+
- lib/.keep
|
170
|
+
- lib/heroku_dnsimple_cert.rb
|
171
|
+
- lib/heroku_dnsimple_cert/cli.rb
|
172
|
+
- lib/heroku_dnsimple_cert/dnsimple_certificate.rb
|
173
|
+
- lib/heroku_dnsimple_cert/heroku_certificate.rb
|
174
|
+
- lib/heroku_dnsimple_cert/heroku_sni.rb
|
175
|
+
- lib/heroku_dnsimple_cert/version.rb
|
176
|
+
homepage: https://github.com/fs/heroku-dnsimple-cert
|
177
|
+
licenses:
|
178
|
+
- MIT
|
179
|
+
metadata: {}
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options: []
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 2.5.1
|
197
|
+
signing_key:
|
198
|
+
specification_version: 4
|
199
|
+
summary: Upload SSL cert from DNSimple to Heroku.
|
200
|
+
test_files: []
|