cert_munger 0.1.1 → 0.2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +2 -3
- data/README.md +1 -1
- data/Rakefile +1 -3
- data/cert_munger.gemspec +1 -2
- data/lib/cert_munger/formatter.rb +23 -3
- data/lib/cert_munger/version.rb +1 -1
- data/spec/certs/one_line_spaces.crt +1 -0
- data/spec/lib/cert_munger_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -7
- data.tar.gz.sig +0 -0
- metadata +10 -22
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc7848d1decd68591525ba643fd8be3bb5979a86
|
4
|
+
data.tar.gz: b8a591e0183a08976a6ffde4f4875101ec60f3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba26f682f4dade354b79f8be9595e3564d981fcf7058e2eea70201f6947393f6dc221210784a72625cfc6ffee44d7a3104c3fdc4dece4ff4b1420f292f2083fd
|
7
|
+
data.tar.gz: 6766db9c810b9c6da996b4efb58a914f5ee20c123d91832fcafd5fdd77b266b8159d15b019f515d4c94583ee6657387daa00caae6a1c104b844214bc83f5a8f4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CertMunger [](http://badge.fury.io/rb/cert_munger)
|
2
2
|
|
3
|
-
[](https://travis-ci.org/stevenhaddox/cert_munger) [](https://gemnasium.com/stevenhaddox/cert_munger) [](https://travis-ci.org/stevenhaddox/cert_munger) [](https://gemnasium.com/stevenhaddox/cert_munger) [](https://codeclimate.com/github/stevenhaddox/cert_munger/coverage) [](https://codeclimate.com/github/stevenhaddox/cert_munger) [](http://inch-ci.org/github/stevenhaddox/cert_munger)
|
4
4
|
|
5
5
|
A gem that takes string input for X509 certificates and attempts to reformat
|
6
6
|
them into a valid certificate. This gem extends the core String class to add
|
data/Rakefile
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'rubocop/rake_task'
|
4
|
-
require 'coveralls/rake/task'
|
5
|
-
Coveralls::RakeTask.new
|
6
4
|
|
7
|
-
task default: [:spec, :rubocop
|
5
|
+
task default: [:spec, :rubocop]
|
8
6
|
|
9
7
|
desc 'Run specs'
|
10
8
|
RSpec::Core::RakeTask.new(:spec)
|
data/cert_munger.gemspec
CHANGED
@@ -23,13 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'awesome_print', '~> 1.2'
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
27
27
|
spec.add_development_dependency 'rack', '~> 1.5'
|
28
28
|
spec.add_development_dependency 'rack-test', '~> 0.6'
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'rubocop', '~> 0.27'
|
31
31
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
32
|
-
spec.add_development_dependency 'simplecov', '~> 0.9'
|
33
32
|
spec.add_development_dependency 'yard', '~> 0.8'
|
34
33
|
|
35
34
|
spec.cert_chain = ['certs/stevenhaddox.pem']
|
@@ -63,12 +63,32 @@ module CertMunger
|
|
63
63
|
# @param raw_cert [String] The string of text you wish to parse into a cert
|
64
64
|
# @return [String] reformatted certificate body
|
65
65
|
def one_line_contents(raw_cert)
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
# Detect if we have newlines, if not, split on spaces
|
67
|
+
if raw_cert.include?('\n')
|
68
|
+
cert_contents = raw_cert.split('\n')
|
69
|
+
else
|
70
|
+
cert_contents = parse_space_delimited_cert(raw_cert)
|
71
|
+
end
|
72
|
+
cert_contents.pop # Remove -----BEGIN CERTIFICATE-----
|
73
|
+
cert_contents.shift # Remove -----END CERTIFICATE-----
|
74
|
+
|
69
75
|
cert_contents.map! { |el| el.match('\W+[t|n|r](.*)')[1] }
|
70
76
|
end
|
71
77
|
|
78
|
+
# Attempts to reformat one-line certificate bodies
|
79
|
+
#
|
80
|
+
# @param raw_cert [String] The string of text you wish to parse into a cert
|
81
|
+
# @return [Array] reformatted certificate content in Array format
|
82
|
+
def parse_space_delimited_cert(raw_cert)
|
83
|
+
cert_contents = raw_cert.split(' ')
|
84
|
+
# "-----BEGIN CERTIFICATE------" fix
|
85
|
+
cert_contents[0] += " #{cert_contents.delete_at(1)}"
|
86
|
+
# "-----END CERTIFICATE------" fix
|
87
|
+
cert_contents[-1] = "#{cert_contents[-2]} #{cert_contents.delete_at(-1)}"
|
88
|
+
|
89
|
+
cert_contents.map { |el| "\\t#{el}" } # Hack it to match expected syntax
|
90
|
+
end
|
91
|
+
|
72
92
|
# Attempts to reformat multi-line certificate bodies
|
73
93
|
#
|
74
94
|
# @param raw_cert [String] The string of text you wish to parse into a cert
|
data/lib/cert_munger/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
-----BEGIN CERTIFICATE----- MIIDQDCCAiigAwIBAgIBAjANBgkqhkiG9w0BAQsFADBCMRMwEQYKCZImiZPyLGQB GRYDb3JnMRkwFwYKCZImiZPyLGQBGRYJcnVieS1sYW5nMRAwDgYDVQQDDAdSdWJ5 IENBMB4XDTE0MTAyMTE0MTU0NFoXDTE1MTAyMTE0MTU0NFowUjETMBEGCgmSJomT 8ixkARkWA29yZzEZMBcGCgmSJomT8ixkARkWCXJ1YnktbGFuZzEgMB4GA1UEAwwX UnVieSBjZXJ0aWZpY2F0ZSByYmNlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw ggEKAoIBAQDA2Cb1QoNx7ghJv/q7yzAr89zyQbOr7wJN+X9/qfRTZi7o31JRrO21 4VFAQeLdf2InfH/yGcME/6dRm0Y9priOShPkRTrerxD8Xf7df/u/R2cUW6WcQUuB fFHp8f1FcYuwxsX2gFNpboukRfWSgIvkXG+BAl/HSUjPyjiEYYTk2nkjOUmFObA8 ip7xJ2n+ZyHl4SggvC+C8QmDQt3dBsZ3C2BovtJ6YQRMJjaEXGWl2fxJfgnJ94aq /M3TP5OUvnwDh8MJq4LuPNPc2PBAAvrQ0SFUaZxlxt9cWtnEGhT6jejBWrik8BNk YGrU9HIpYeg4a9i5GRDZ6s/xlZ4X+pjlAgMBAAGjMTAvMA4GA1UdDwEB/wQEAwIH gDAdBgNVHQ4EFgQUPGVKgxbUCl/OiPHnzeN3qR5BMe4wDQYJKoZIhvcNAQELBQAD ggEBAFnSbIvnYubRuEcGux5m1y2UlzSg/GyNDhnWsfPqQQ7FfolFTk6W8+xKuRSg foiuV2Od0n1nBMd9ePzoF5QabMHCK1Al2o/P7PkUPgmuAnWWdTLikNtt6H6v9WLe R9Ng37xv9jOVFOQjYCYvc94cJe1OBXW7ppkRY3kUQQbIrO7Imwi8gB8KT4qwu/Ld Xt53I/aFMQ0JSkqhJ4Bhff/Ol2RcDjEt4U6Hne6lRVB9qCAz0gE8MN4HagWOlS1U Nxd+cde+JIVBHuDz63gExGPCdLBRL/Mi3LORpZT41/ryw3JCqTir0dgPXsVTtJPr iMZ2EcsmShyBUKKj2AIok5gZzgM= -----END CERTIFICATE-----
|
@@ -15,6 +15,7 @@ describe CertMunger do
|
|
15
15
|
let!(:certificate) { OpenSSL::X509::Certificate.new(raw_cert) }
|
16
16
|
let!(:malformed_cert) { File.read("spec/certs/malformed.crt") }
|
17
17
|
let!(:one_line_cert) { File.read("spec/certs/one_line.crt") }
|
18
|
+
let!(:one_line_spaces_cert) { File.read("spec/certs/one_line_spaces.crt") }
|
18
19
|
let!(:passenger_nginx_cert) { File.read("spec/certs/passenger.crt") }
|
19
20
|
|
20
21
|
#
|
@@ -36,6 +37,11 @@ describe CertMunger do
|
|
36
37
|
new_cert = subject.to_cert(one_line_cert)
|
37
38
|
expect(new_cert.to_s).to eq(certificate.to_s)
|
38
39
|
end
|
40
|
+
|
41
|
+
it "should parse a certificate with all content in one line, space delimited" do
|
42
|
+
new_cert = subject.to_cert(one_line_spaces_cert)
|
43
|
+
expect(new_cert.to_s).to eq(certificate.to_s)
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
describe "#to_cert" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
4
|
-
SimpleCov.start do
|
5
|
-
add_filter '/spec/'
|
6
|
-
end
|
7
|
-
# SimpleCov always comes before **anything** else
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
8
3
|
|
9
4
|
require_relative '../lib/cert_munger'
|
10
5
|
require 'awesome_print'
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cert_munger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Haddox
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
42qdwEXvvkODZAD6KAIXPdmbMfBgPbcd+B/4eUA0PyKo+4dgL1NuqX4MPWToevIZ
|
31
31
|
O8EKLF2X7NmC6FY1bOsSj/J8r1SOkx0rxgF+geRvY1P+hfNjDfxTsjU=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: logging
|
@@ -75,19 +75,19 @@ dependencies:
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '1.6'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
78
|
+
name: codeclimate-test-reporter
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0
|
83
|
+
version: '0'
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0
|
90
|
+
version: '0'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rack
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,20 +158,6 @@ dependencies:
|
|
158
158
|
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '3.1'
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
name: simplecov
|
163
|
-
requirement: !ruby/object:Gem::Requirement
|
164
|
-
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: '0.9'
|
168
|
-
type: :development
|
169
|
-
prerelease: false
|
170
|
-
version_requirements: !ruby/object:Gem::Requirement
|
171
|
-
requirements:
|
172
|
-
- - "~>"
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: '0.9'
|
175
161
|
- !ruby/object:Gem::Dependency
|
176
162
|
name: yard
|
177
163
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,6 +197,7 @@ files:
|
|
211
197
|
- spec/certs/create_spec_cert.rb
|
212
198
|
- spec/certs/malformed.crt
|
213
199
|
- spec/certs/one_line.crt
|
200
|
+
- spec/certs/one_line_spaces.crt
|
214
201
|
- spec/certs/passenger.crt
|
215
202
|
- spec/certs/ruby_user.crt
|
216
203
|
- spec/certs/ruby_user.pub
|
@@ -237,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
224
|
version: '0'
|
238
225
|
requirements: []
|
239
226
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.4.
|
227
|
+
rubygems_version: 2.4.5.1
|
241
228
|
signing_key:
|
242
229
|
specification_version: 4
|
243
230
|
summary: Reformat commonly malformatted X509 strings.
|
@@ -245,6 +232,7 @@ test_files:
|
|
245
232
|
- spec/certs/create_spec_cert.rb
|
246
233
|
- spec/certs/malformed.crt
|
247
234
|
- spec/certs/one_line.crt
|
235
|
+
- spec/certs/one_line_spaces.crt
|
248
236
|
- spec/certs/passenger.crt
|
249
237
|
- spec/certs/ruby_user.crt
|
250
238
|
- spec/certs/ruby_user.pub
|
metadata.gz.sig
CHANGED
Binary file
|