cert-check 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +26 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +8 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/cert-check.gemspec +27 -0
- data/exe/cert-check +5 -0
- data/lib/cert_check.rb +6 -0
- data/lib/cert_check/cli.rb +65 -0
- data/lib/cert_check/version.rb +3 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a99f7f6d445ff47d55bfba2497e5bfb6f86f06b3aa33cbf46ab6f92db3cb611
|
4
|
+
data.tar.gz: e13a4749d590049f811428392741d24d2420c552d69a9fecf35a9be6e22dc2b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 160d9564151aea883aa5ee6ef7e2a66cf2c5317948bc7c87744aa3f59569a99826b0470634252ed3d66d07bffc50999f48cab813e995cf314fac260c65c71879
|
7
|
+
data.tar.gz: 823a6d1b69074d0a4c81055ce4ba6c82871eb2982b8a9fbd7b550857a5618250b90116d3bd0daed7aed215613bc7863ca999add7ad692437fc421286f3aab86a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/FrozenStringLiteralComment:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/AbcSize:
|
8
|
+
Max: 50
|
9
|
+
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Max: 50
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Max: 50
|
15
|
+
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 120
|
18
|
+
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/MutableConstant:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/PercentLiteralDelimiters:
|
26
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 ryoma123
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# cert-check
|
2
|
+
|
3
|
+
CLI tool for Check a certificate files and return information.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cert-check'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ gem install cert-check
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Passing one or more certificate file paths as arguments.
|
28
|
+
|
29
|
+
```sh
|
30
|
+
$ cert-check info /tmp/www.example.org.crt /tmp/github.com.crt
|
31
|
+
CertFile: /tmp/www.example.org.cert
|
32
|
+
Issuer: DigiCert SHA2 Secure Server CA
|
33
|
+
NotBefore: 2018-11-28 09:00:00 +0900
|
34
|
+
NotAfter: 2020-12-02 21:00:00 +0900
|
35
|
+
CommonName: www.example.org
|
36
|
+
SANs: [www.example.org example.com example.edu example.net example.org www.example.com www.example.edu www.example.net]
|
37
|
+
|
38
|
+
CertFile: /tmp/github.com.cert
|
39
|
+
Issuer: DigiCert SHA2 Extended Validation Server CA
|
40
|
+
NotBefore: 2018-05-08 09:00:00 +0900
|
41
|
+
NotAfter: 2020-06-03 21:00:00 +0900
|
42
|
+
CommonName: github.com
|
43
|
+
SANs: [github.com www.github.com]
|
44
|
+
```
|
45
|
+
|
46
|
+
Get help on this command.
|
47
|
+
|
48
|
+
```sh
|
49
|
+
$ cert-check help
|
50
|
+
```
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/cert-check.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'cert_check/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'cert-check'
|
7
|
+
spec.version = CertCheck::VERSION
|
8
|
+
spec.authors = ['ryoma123']
|
9
|
+
spec.email = ['ryoma.ono.2661@gmail.com']
|
10
|
+
spec.summary = 'CLI tool for check the certificate files and return information.'
|
11
|
+
spec.description = 'CLI tool for check the certificate files and return information.'
|
12
|
+
spec.homepage = 'https://github.com/ryoma123/cert-check'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'thor', '~> 0.20.3'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.63.1'
|
27
|
+
end
|
data/exe/cert-check
ADDED
data/lib/cert_check.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module CertCheck
|
5
|
+
# Cert-check's command line interface
|
6
|
+
class CLI < Thor
|
7
|
+
desc 'info [CERTIFICATE FILES]', 'Check certificate files and return information'
|
8
|
+
def info(*files)
|
9
|
+
if files.empty?
|
10
|
+
say_status :error,
|
11
|
+
'Pass one or more certificate file paths as arguments.',
|
12
|
+
:red
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
files.each do |file|
|
17
|
+
puts "CertFile: #{file}"
|
18
|
+
|
19
|
+
begin
|
20
|
+
@cert = OpenSSL::X509::Certificate.new File.read file
|
21
|
+
rescue OpenSSL::X509::CertificateError => e
|
22
|
+
say_status :error,
|
23
|
+
"Certificate file is incorrect. (#{e.class}: #{e.message})\n\n",
|
24
|
+
:red
|
25
|
+
next
|
26
|
+
rescue StandardError => e
|
27
|
+
say_status :error, "#{e.class}: #{e.message}\n\n", :red
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
resources
|
32
|
+
puts template
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def resources
|
39
|
+
@subject = array_to_hash(@cert.subject.to_a)
|
40
|
+
@issuer = array_to_hash(@cert.issuer.to_a)
|
41
|
+
@not_before = @cert.not_before.getlocal
|
42
|
+
@not_after = @cert.not_after.getlocal
|
43
|
+
@sans = sans_to_array
|
44
|
+
end
|
45
|
+
|
46
|
+
def array_to_hash(arr)
|
47
|
+
Hash[*arr.flatten.reject { |a| a.is_a?(Integer) }]
|
48
|
+
end
|
49
|
+
|
50
|
+
def sans_to_array
|
51
|
+
@cert.to_text.scan(/Subject Alternative Name:\s*([^\n\r]*)/).join(',')
|
52
|
+
.scan(/DNS:([^,]*)/).flatten
|
53
|
+
end
|
54
|
+
|
55
|
+
def template
|
56
|
+
<<~OUT
|
57
|
+
Issuer: #{@issuer['CN']}
|
58
|
+
NotBefore: #{@not_before}
|
59
|
+
NotAfter: #{@not_after}
|
60
|
+
CommonName: #{@subject['CN']}
|
61
|
+
SANs: [#{@sans.join(' ')}]\n
|
62
|
+
OUT
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cert-check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ryoma123
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.20.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.20.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.63.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.63.1
|
83
|
+
description: CLI tool for check the certificate files and return information.
|
84
|
+
email:
|
85
|
+
- ryoma.ono.2661@gmail.com
|
86
|
+
executables:
|
87
|
+
- cert-check
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- cert-check.gemspec
|
102
|
+
- exe/cert-check
|
103
|
+
- lib/cert_check.rb
|
104
|
+
- lib/cert_check/cli.rb
|
105
|
+
- lib/cert_check/version.rb
|
106
|
+
homepage: https://github.com/ryoma123/cert-check
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubygems_version: 3.0.2
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: CLI tool for check the certificate files and return information.
|
129
|
+
test_files: []
|