vagrant-trellis-cert 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github_changelog_generator +1 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/README.md +7 -0
- data/lib/vagrant_plugins/trellis_cert/command/distrust.rb +49 -0
- data/lib/vagrant_plugins/trellis_cert/command/root.rb +5 -0
- data/lib/vagrant_plugins/trellis_cert/command/trust.rb +21 -15
- data/lib/vagrant_plugins/trellis_cert/identity.rb +1 -1
- data/lib/vagrant_plugins/trellis_cert/system.rb +2 -2
- data/lib/vagrant_plugins/trellis_cert/system/darwin.rb +14 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a80cecdab393ada97a1447baafb77d3a170d50e
|
4
|
+
data.tar.gz: 8f08f111c4bc44256828e310ad1e2de232e0c74c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc2665f000b8b0056d7882dede8363cf4d62359cd455ec337a14dd824260f904abc3a8362af9fa259279cc754144db0ee78e35135382f62692bff20b34b19a9
|
7
|
+
data.tar.gz: 9c47bd2770f4f0218cd9f9e601cbc232d68666494cadd3273b570c1c2339230ba57c8dc7f5b665c3c0133ad9c832423d64ff291e43adc411e4f2d6eac8584271
|
data/.github_changelog_generator
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
unreleased=true
|
2
|
-
future-release=v0.
|
2
|
+
future-release=v0.4.0
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.4.0](https://github.com/TypistTech/vagrant-trellis-cert/tree/v0.4.0) (2017-10-05)
|
4
|
+
[Full Changelog](https://github.com/TypistTech/vagrant-trellis-cert/compare/v0.3.0...v0.4.0)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Add `distrust` subcommand [\#21](https://github.com/TypistTech/vagrant-trellis-cert/issues/21)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Add `distrust` subcommand [\#37](https://github.com/TypistTech/vagrant-trellis-cert/pull/37) ([TangRufus](https://github.com/TangRufus))
|
13
|
+
|
3
14
|
## [v0.3.0](https://github.com/TypistTech/vagrant-trellis-cert/tree/v0.3.0) (2017-09-18)
|
4
15
|
[Full Changelog](https://github.com/TypistTech/vagrant-trellis-cert/compare/v0.2.0...v0.3.0)
|
5
16
|
|
@@ -10,6 +21,7 @@
|
|
10
21
|
|
11
22
|
**Merged pull requests:**
|
12
23
|
|
24
|
+
- Version bump 0.3.0 [\#36](https://github.com/TypistTech/vagrant-trellis-cert/pull/36) ([TangRufus](https://github.com/TangRufus))
|
13
25
|
- Determine current VM via `vm-id` as a vagrant plugin should [\#35](https://github.com/TypistTech/vagrant-trellis-cert/pull/35) ([TangRufus](https://github.com/TangRufus))
|
14
26
|
- Extract class `Result` [\#34](https://github.com/TypistTech/vagrant-trellis-cert/pull/34) ([TangRufus](https://github.com/TangRufus))
|
15
27
|
- Rename module Commands --\> Command [\#33](https://github.com/TypistTech/vagrant-trellis-cert/pull/33) ([TangRufus](https://github.com/TangRufus))
|
data/README.md
CHANGED
@@ -39,11 +39,13 @@ $ vagrant plugin install vagrant-trellis-cert
|
|
39
39
|
|
40
40
|
```bash
|
41
41
|
Usage: vagrant trellis-cert trust [options] [vm-id]
|
42
|
+
Usage: vagrant trellis-cert distrust [options] [vm-id]
|
42
43
|
|
43
44
|
-h, --help Print this help
|
44
45
|
|
45
46
|
# Example: Running within Trellis directory
|
46
47
|
$ vagrant trellis-cert trust
|
48
|
+
$ vagrant trellis-cert distrust
|
47
49
|
|
48
50
|
# Example: Specify VM id
|
49
51
|
$ vagrant global-status
|
@@ -52,6 +54,7 @@ id name provider state directory
|
|
52
54
|
fb90ab5 default virtualbox running /Users/me/Code/trellis
|
53
55
|
|
54
56
|
$ vagrant trellis-cert trust fb90ab5
|
57
|
+
$ vagrant trellis-cert distrust fb90ab5
|
55
58
|
```
|
56
59
|
|
57
60
|
## Going super lazy
|
@@ -69,6 +72,10 @@ Vagrant.configure('2') do |config|
|
|
69
72
|
config.trigger.after :provision, :stdout => true do
|
70
73
|
run "vagrant trellis-cert trust"
|
71
74
|
end
|
75
|
+
|
76
|
+
config.trigger.after :destroy, :stdout => true do
|
77
|
+
run "vagrant trellis-cert distrust"
|
78
|
+
end
|
72
79
|
end
|
73
80
|
```
|
74
81
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'vagrant_plugins/trellis_cert/ssl_config'
|
4
|
+
require 'vagrant_plugins/trellis_cert/system'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module TrellisCert
|
8
|
+
module Command
|
9
|
+
class Distrust < Vagrant.plugin('2', :command)
|
10
|
+
def execute
|
11
|
+
_options, argv = parse_options!
|
12
|
+
|
13
|
+
@env.ui.info('Removing certificates...')
|
14
|
+
|
15
|
+
hosts = SSLConfig.new(root_path: machine_root_path(argv))
|
16
|
+
.canonicals
|
17
|
+
result = System.build
|
18
|
+
.distrust(hosts)
|
19
|
+
|
20
|
+
result.print(ui: @env.ui)
|
21
|
+
|
22
|
+
result.exit_code
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parse_options!
|
28
|
+
options = {}
|
29
|
+
opts = OptionParser.new do |o|
|
30
|
+
o.banner = 'Usage: vagrant trellis-cert distrust [options] [vm-id]'
|
31
|
+
o.separator ''
|
32
|
+
|
33
|
+
o.on('-h', '--help', 'Print this help') do
|
34
|
+
@env.ui.info(opts)
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
end
|
38
|
+
[options, parse_options(opts)]
|
39
|
+
end
|
40
|
+
|
41
|
+
def machine_root_path(argv)
|
42
|
+
with_target_vms(argv) do |machine|
|
43
|
+
return machine.env.root_path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -10,23 +10,13 @@ module VagrantPlugins
|
|
10
10
|
def execute
|
11
11
|
_options, argv = parse_options!
|
12
12
|
|
13
|
-
|
14
|
-
result = nil
|
13
|
+
@env.ui.info('Importing certificates...')
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
machine.env.ui.info('Importing certificates...')
|
20
|
-
|
21
|
-
Dir.mktmpdir do |tmp_dir|
|
22
|
-
result = System.build(
|
23
|
-
hosts: SSLConfig.new(root_path: machine.env.root_path).canonicals,
|
24
|
-
tmp_dir: tmp_dir
|
25
|
-
).trust
|
26
|
-
end
|
15
|
+
hosts = SSLConfig.new(root_path: machine_root_path(argv))
|
16
|
+
.canonicals
|
17
|
+
result = trust(hosts)
|
27
18
|
|
28
|
-
|
29
|
-
end
|
19
|
+
result.print(ui: @env.ui)
|
30
20
|
|
31
21
|
result.exit_code
|
32
22
|
end
|
@@ -46,6 +36,22 @@ module VagrantPlugins
|
|
46
36
|
end
|
47
37
|
[options, parse_options(opts)]
|
48
38
|
end
|
39
|
+
|
40
|
+
def machine_root_path(argv)
|
41
|
+
with_target_vms(argv) do |machine|
|
42
|
+
# Machine must be up so that we can download SSL certificates.
|
43
|
+
raise Vagrant::Errors::SSHNotReady unless machine.communicate.ready?
|
44
|
+
|
45
|
+
return machine.env.root_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def trust(hosts)
|
50
|
+
Dir.mktmpdir do |tmp_dir|
|
51
|
+
return System.build
|
52
|
+
.trust(hosts: hosts, tmp_dir: tmp_dir)
|
53
|
+
end
|
54
|
+
end
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
@@ -5,12 +5,12 @@ require 'vagrant_plugins/trellis_cert/system/darwin'
|
|
5
5
|
module VagrantPlugins
|
6
6
|
module TrellisCert
|
7
7
|
module System
|
8
|
-
def self.build
|
8
|
+
def self.build
|
9
9
|
unless Vagrant::Util::Platform.darwin?
|
10
10
|
raise 'vagrant-trellis-cert only works on macOS. Pull requests are welcome.'
|
11
11
|
end
|
12
12
|
|
13
|
-
Darwin.new
|
13
|
+
Darwin.new
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -8,17 +8,12 @@ module VagrantPlugins
|
|
8
8
|
class Darwin
|
9
9
|
KEYCHAIN = '~/Library/Keychains/login.keychain'
|
10
10
|
|
11
|
-
def
|
12
|
-
@hosts = hosts
|
13
|
-
@tmp_dir = tmp_dir
|
14
|
-
end
|
15
|
-
|
16
|
-
def trust
|
11
|
+
def trust(hosts:, tmp_dir:)
|
17
12
|
Result.new.tap do |result|
|
18
|
-
|
19
|
-
cert_path = "#{
|
13
|
+
hosts.map do |host|
|
14
|
+
cert_path = "#{tmp_dir}/#{host}.pem"
|
20
15
|
|
21
|
-
# Download
|
16
|
+
# Download cert
|
22
17
|
system("openssl s_client -showcerts -connect #{host}:443 </dev/null 2>/dev/null | \
|
23
18
|
openssl x509 -outform PEM > #{cert_path} 2>/dev/null")
|
24
19
|
|
@@ -28,6 +23,16 @@ module VagrantPlugins
|
|
28
23
|
end
|
29
24
|
end
|
30
25
|
end
|
26
|
+
|
27
|
+
def distrust(hosts)
|
28
|
+
Result.new.tap do |result|
|
29
|
+
hosts.map do |host|
|
30
|
+
is_success = system("security delete-certificate -c #{host} #{KEYCHAIN} >/dev/null 2>/dev/null")
|
31
|
+
|
32
|
+
result.add(host: host, is_success: is_success)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-trellis-cert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tang Rufus
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- README.md
|
73
73
|
- Rakefile
|
74
74
|
- lib/vagrant-trellis-cert.rb
|
75
|
+
- lib/vagrant_plugins/trellis_cert/command/distrust.rb
|
75
76
|
- lib/vagrant_plugins/trellis_cert/command/root.rb
|
76
77
|
- lib/vagrant_plugins/trellis_cert/command/trust.rb
|
77
78
|
- lib/vagrant_plugins/trellis_cert/config.rb
|