poise-tls-remote-file 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +24 -1
- data/lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb +2 -1
- data/lib/poise_tls_remote_file/version.rb +1 -1
- data/poise-tls-remote-file.gemspec +1 -1
- data/test/cookbook/recipes/default.rb +31 -1
- data/test/gemfiles/master.gemfile +2 -1
- data/test/integration/default/serverspec/default_spec.rb +12 -0
- data/test/spec/resources/poise_tls_remote_file_spec.rb +26 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2be95b7dbc16895507b6db4ca1f1a24d697b9bf9
|
4
|
+
data.tar.gz: ede12925c5f02d55b61b10342af141cda463b7ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6e309db92644bb012a8bb3e54aa1d2accd077a2c1ceef13c1ed96717fbb2f9f54f9becd44411c5742ca0a98300afbc117c6bd7d75e0e6fdc20d14ea478c5bf
|
7
|
+
data.tar.gz: b176751d01fe72994a582a6b408a3de0c95bd0a3d53873a4dfaddf835b685e930a29307da14e1a76c0a404ca192d25a996ebdbf56927e9cb318df02bbe210636
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
|
9
9
|
|
10
10
|
A [Chef](https://www.chef.io/) cookbook to download files over HTTPS using TLS
|
11
|
-
client certificate authentication.
|
11
|
+
client certificate authentication or with custom CA certificates.
|
12
12
|
|
13
13
|
## Quick Start
|
14
14
|
|
@@ -21,6 +21,29 @@ tls_remote_file '/path/to/file' do
|
|
21
21
|
end
|
22
22
|
```
|
23
23
|
|
24
|
+
To specify a CA certificate for the download:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
tls_remote_file '/path/to/file' do
|
28
|
+
ca '/etc/ssl/mycompany.crt'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
Certificates and keys can also be specified in-line as strings or retrieved
|
33
|
+
from other APIs like Chef data bags:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
tls_remote_file '/path/to/file' do
|
37
|
+
client_cert data_bag_item('client_keys', node.chef_environment)['key']
|
38
|
+
ca <<-EOH
|
39
|
+
-----BEGIN CERTIFICATE-----
|
40
|
+
MIIFEjCCAvoCAQIwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV
|
41
|
+
...
|
42
|
+
-----END CERTIFICATE-----
|
43
|
+
EOH
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
24
47
|
## Attributes
|
25
48
|
|
26
49
|
* `node['poise-tls-remote-file']['client_cert']` – Default client_cert for all
|
@@ -129,7 +129,8 @@ module PoiseTlsRemoteFile
|
|
129
129
|
super(*inner_args).tap do |client|
|
130
130
|
client.http_client.cert = client_cert if client_cert
|
131
131
|
client.http_client.key = client_key if client_key
|
132
|
-
|
132
|
+
# cert_store is nil if this is not an HTTPS URL.
|
133
|
+
ca.each {|cert| client.http_client.cert_store.add_cert(cert) if cert } if client.http_client.cert_store
|
133
134
|
end
|
134
135
|
end
|
135
136
|
})
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.version = PoiseTlsRemoteFile::VERSION
|
24
24
|
spec.authors = ['Noah Kantrowitz']
|
25
25
|
spec.email = %w{noah@coderanger.net}
|
26
|
-
spec.description = 'A Chef cookbook
|
26
|
+
spec.description = 'A Chef cookbook cookbook to download files over HTTPS using TLS client certificate authentication.'
|
27
27
|
spec.summary = spec.description
|
28
28
|
spec.homepage = 'https://github.com/poise/poise-tls-remote-file'
|
29
29
|
spec.license = 'Apache 2.0'
|
@@ -68,6 +68,19 @@ http {
|
|
68
68
|
root /test;
|
69
69
|
}
|
70
70
|
}
|
71
|
+
|
72
|
+
server {
|
73
|
+
listen 444;
|
74
|
+
ssl on;
|
75
|
+
server_name localhost;
|
76
|
+
|
77
|
+
ssl_certificate /test/server.crt;
|
78
|
+
ssl_certificate_key /test/server.key;
|
79
|
+
|
80
|
+
location / {
|
81
|
+
root /test;
|
82
|
+
}
|
83
|
+
}
|
71
84
|
}
|
72
85
|
EOH
|
73
86
|
end
|
@@ -90,7 +103,24 @@ tls_remote_file '/output2' do
|
|
90
103
|
ca '/test/ca.crt'
|
91
104
|
end
|
92
105
|
|
106
|
+
# Test with no client key, just normal HTTPS as fallback.
|
107
|
+
tls_remote_file '/output3' do
|
108
|
+
source 'https://localhost:444/target'
|
109
|
+
ca '/test/ca.crt'
|
110
|
+
end
|
111
|
+
|
112
|
+
# And even more fallback, just plain HTTP.
|
113
|
+
tls_remote_file '/output4' do
|
114
|
+
source 'http://localhost/target'
|
115
|
+
end
|
116
|
+
|
117
|
+
# HTTP even with a CA cert.
|
118
|
+
tls_remote_file '/output5' do
|
119
|
+
source 'http://localhost/target'
|
120
|
+
ca '/test/ca.crt'
|
121
|
+
end
|
122
|
+
|
93
123
|
# Make sure I didn't break normal remote_file.
|
94
|
-
remote_file '/
|
124
|
+
remote_file '/output6' do
|
95
125
|
source 'http://localhost/target'
|
96
126
|
end
|
@@ -17,8 +17,9 @@
|
|
17
17
|
eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
|
18
18
|
|
19
19
|
gem 'chef', github: 'chef/chef'
|
20
|
-
gem 'ohai', github: 'chef/ohai'
|
21
20
|
gem 'halite', github: 'poise/halite'
|
21
|
+
gem 'ohai', github: 'chef/ohai'
|
22
22
|
gem 'poise', github: 'poise/poise'
|
23
23
|
gem 'poise-boiler', github: 'poise/poise-boiler'
|
24
|
+
gem 'poise-profiler', github: 'poise/poise-profiler'
|
24
25
|
gem 'poise-service', github: 'poise/poise-service'
|
@@ -28,3 +28,15 @@ end
|
|
28
28
|
describe file('/output3') do
|
29
29
|
its(:content) { is_expected.to eq "Hello world\n" }
|
30
30
|
end
|
31
|
+
|
32
|
+
describe file('/output4') do
|
33
|
+
its(:content) { is_expected.to eq "Hello world\n" }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe file('/output5') do
|
37
|
+
its(:content) { is_expected.to eq "Hello world\n" }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe file('/output6') do
|
41
|
+
its(:content) { is_expected.to eq "Hello world\n" }
|
42
|
+
end
|
@@ -327,4 +327,30 @@ EOH
|
|
327
327
|
run_chef
|
328
328
|
end
|
329
329
|
end # /context with node["poise-tls-remote-file"]["ca"]
|
330
|
+
|
331
|
+
context 'with no additional properties' do
|
332
|
+
it { expect { run_chef }.to_not raise_error }
|
333
|
+
end # /context with no additional properties
|
334
|
+
|
335
|
+
context 'with an HTTP URL' do
|
336
|
+
before do
|
337
|
+
allow(stub_http).to receive(:cert_store).and_return(nil)
|
338
|
+
end
|
339
|
+
recipe do
|
340
|
+
tls_remote_file node['test_tempfile'] do
|
341
|
+
source 'http://example.com/'
|
342
|
+
end
|
343
|
+
end
|
344
|
+
it { expect { run_chef }.to_not raise_error }
|
345
|
+
|
346
|
+
context 'with a CA cert' do
|
347
|
+
recipe do
|
348
|
+
tls_remote_file node['test_tempfile'] do
|
349
|
+
source 'http://example.com/'
|
350
|
+
ca '/test/ca.crt'
|
351
|
+
end
|
352
|
+
end
|
353
|
+
it { expect { run_chef }.to_not raise_error }
|
354
|
+
end # /context with a CA cert
|
355
|
+
end # /context with an HTTP URL
|
330
356
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poise-tls-remote-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Kantrowitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -72,7 +72,8 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.0'
|
75
|
-
description: A Chef cookbook
|
75
|
+
description: A Chef cookbook cookbook to download files over HTTPS using TLS client
|
76
|
+
certificate authentication.
|
76
77
|
email:
|
77
78
|
- noah@coderanger.net
|
78
79
|
executables: []
|
@@ -153,7 +154,8 @@ rubyforge_project:
|
|
153
154
|
rubygems_version: 2.6.11
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
|
-
summary: A Chef cookbook
|
157
|
+
summary: A Chef cookbook cookbook to download files over HTTPS using TLS client certificate
|
158
|
+
authentication.
|
157
159
|
test_files:
|
158
160
|
- test/cookbook/files/ca.crt
|
159
161
|
- test/cookbook/files/ca.key
|