ssl_expiry 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -7
- data/CHANGELOG.md +6 -0
- data/README.md +8 -0
- data/lib/ssl_expiry.rb +21 -8
- data/lib/ssl_expiry/version.rb +1 -1
- data/testing/check-ssl +66 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96cbba1150d51acb0a1f4d27f9634e3b7f92f2ea4fa4f41bae2e848484a0c078
|
4
|
+
data.tar.gz: 5c0cb052de1b6da7e3881dcbc7aafafa048e991404c9c535f9a401c9248e3c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c86634f01a0cb849634e2ba8b5d0eac5f931f8193a928a1d6584f926679e6d49b6772f3af77e3f161bd38bc9d2ee5a29c9436dc0030c2d8b1cdf7983851874f9
|
7
|
+
data.tar.gz: 7038c81c4247218ae59484d62e853b892135ae52ec2ef2e66d1f207c9ec55dd250dcbe93f0facf1bbbdde89604c1e88a444574baf25bcbd8619f06f5d306e11e
|
data/.rubocop.yml
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
Layout/IndentationWidth:
|
2
2
|
Width: 4
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
Layout/LineLength:
|
5
|
+
Enabled: false
|
6
6
|
|
7
|
-
Metrics/
|
7
|
+
Metrics/AbcSize:
|
8
8
|
Enabled: false
|
9
9
|
|
10
10
|
Metrics/BlockLength:
|
11
|
-
|
11
|
+
Enabled: false
|
12
12
|
|
13
13
|
Metrics/CyclomaticComplexity:
|
14
|
-
|
14
|
+
Enabled: false
|
15
15
|
|
16
16
|
Metrics/MethodLength:
|
17
|
-
|
17
|
+
Enabled: false
|
18
18
|
|
19
19
|
Metrics/PerceivedComplexity:
|
20
|
-
|
20
|
+
Enabled: false
|
21
21
|
|
22
22
|
Style/GlobalVars:
|
23
23
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -72,6 +72,14 @@ There is a command line tool included with this gem.
|
|
72
72
|
----------------------------------------------------------------------------------------------------
|
73
73
|
```
|
74
74
|
|
75
|
+
### Custom port
|
76
|
+
|
77
|
+
If you want to check an SSL expiry on a custom port you can do this by adding the port to the end of the domain.
|
78
|
+
|
79
|
+
```
|
80
|
+
check-ssl -d antiphoton.com:8080
|
81
|
+
```
|
82
|
+
|
75
83
|
## Development
|
76
84
|
|
77
85
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/ssl_expiry.rb
CHANGED
@@ -14,18 +14,25 @@ module SSLExpiry
|
|
14
14
|
# Docs to follow
|
15
15
|
#
|
16
16
|
class SSLExpiry
|
17
|
-
def self.get_cert(domain_name, verify = false)
|
17
|
+
def self.get_cert(domain_name, supplied_port = nil, verify = false)
|
18
18
|
begin
|
19
19
|
cert = nil
|
20
20
|
|
21
21
|
uri = URI::HTTPS.build(host: domain_name)
|
22
|
-
|
22
|
+
|
23
|
+
port = if supplied_port.nil?
|
24
|
+
uri.port
|
25
|
+
else
|
26
|
+
supplied_port
|
27
|
+
end
|
28
|
+
|
29
|
+
http = Net::HTTP.new(uri.host, port)
|
23
30
|
|
24
31
|
http.use_ssl = true
|
25
32
|
http.verify_mode = verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
26
|
-
http.open_timeout =
|
27
|
-
http.read_timeout =
|
28
|
-
http.ssl_timeout =
|
33
|
+
http.open_timeout = 5
|
34
|
+
http.read_timeout = 5
|
35
|
+
http.ssl_timeout = 5
|
29
36
|
|
30
37
|
http.start do |h|
|
31
38
|
cert = h.peer_cert
|
@@ -48,7 +55,13 @@ module SSLExpiry
|
|
48
55
|
|
49
56
|
domains.each do |domain|
|
50
57
|
begin
|
51
|
-
|
58
|
+
parts = domain.split(':')
|
59
|
+
|
60
|
+
cert = if parts.length == 2
|
61
|
+
get_cert(parts[0], parts[1])
|
62
|
+
else
|
63
|
+
get_cert(parts[0])
|
64
|
+
end
|
52
65
|
rescue SSLError => e
|
53
66
|
results[domain] = { 'status' => 400, 'error' => e.message }
|
54
67
|
next
|
@@ -72,7 +85,7 @@ module SSLExpiry
|
|
72
85
|
delim = '-' * width
|
73
86
|
|
74
87
|
puts(delim)
|
75
|
-
printf(" %-
|
88
|
+
printf(" %-30<header1>s | %<header2>s\n", header1: 'Domain', header2: 'Status')
|
76
89
|
puts(delim)
|
77
90
|
results.each do |domain, details|
|
78
91
|
status = if details['status'] == 400
|
@@ -80,7 +93,7 @@ module SSLExpiry
|
|
80
93
|
else
|
81
94
|
format('expires on %<expires_in>s (in %<expires_on>s days) [CN=%<common_name>s]', expires_in: details['expires_on'], expires_on: details['expires_in'], common_name: details['common_name'])
|
82
95
|
end
|
83
|
-
printf(" %-
|
96
|
+
printf(" %-30<domain>s | %<status>s\n", domain: domain, status: status)
|
84
97
|
end
|
85
98
|
puts(delim)
|
86
99
|
end
|
data/lib/ssl_expiry/version.rb
CHANGED
data/testing/check-ssl
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
require 'ssl_expiry'
|
8
|
+
|
9
|
+
# -------------------------------------------------------------------------------- #
|
10
|
+
# Process Arguments #
|
11
|
+
# -------------------------------------------------------------------------------- #
|
12
|
+
# This function will process the input from the command line and work out what it #
|
13
|
+
# is that the user wants to see. #
|
14
|
+
# #
|
15
|
+
# This is the main processing function where all the processing logic is handled. #
|
16
|
+
# -------------------------------------------------------------------------------- #
|
17
|
+
|
18
|
+
def process_arguments
|
19
|
+
options = {}
|
20
|
+
# Enforce the presence of
|
21
|
+
mandatory = %I[domain]
|
22
|
+
|
23
|
+
optparse = OptionParser.new do |opts|
|
24
|
+
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
25
|
+
|
26
|
+
opts.on('-h', '--help', 'Display this screen') do
|
27
|
+
puts opts
|
28
|
+
exit(1)
|
29
|
+
end
|
30
|
+
opts.on('-d', '--domain string', 'The domain name to check') do |domain|
|
31
|
+
options[:domain] = domain
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
begin
|
36
|
+
optparse.parse!
|
37
|
+
options[:message] = ARGF.read unless STDIN.tty? # override message parameter if data is piped in
|
38
|
+
missing = mandatory.select { |param| options[param].nil? }
|
39
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
40
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
41
|
+
puts e.to_s
|
42
|
+
puts optparse
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
results = SSLExpiry::SSLExpiry.check_certificates(options[:domain])
|
47
|
+
SSLExpiry::SSLExpiry.display_results(results)
|
48
|
+
end
|
49
|
+
|
50
|
+
# -------------------------------------------------------------------------------- #
|
51
|
+
# Main() #
|
52
|
+
# -------------------------------------------------------------------------------- #
|
53
|
+
# The main function where all of the heavy lifting and script config is done. #
|
54
|
+
# -------------------------------------------------------------------------------- #
|
55
|
+
|
56
|
+
def main
|
57
|
+
process_arguments
|
58
|
+
end
|
59
|
+
|
60
|
+
main
|
61
|
+
|
62
|
+
# -------------------------------------------------------------------------------- #
|
63
|
+
# End of Script #
|
64
|
+
# -------------------------------------------------------------------------------- #
|
65
|
+
# This is the end - nothing more to see here. #
|
66
|
+
# -------------------------------------------------------------------------------- #
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssl_expiry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Gurney aka Wolf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- spec/spec_helper.rb
|
143
143
|
- spec/ssl_expiry_spec.rb
|
144
144
|
- ssl_expiry.gemspec
|
145
|
+
- testing/check-ssl
|
145
146
|
homepage: https://github.com/AntiPhotonltd/ssl_expiry
|
146
147
|
licenses:
|
147
148
|
- MIT
|
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
162
|
- !ruby/object:Gem::Version
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.1.2
|
165
166
|
signing_key:
|
166
167
|
specification_version: 4
|
167
168
|
summary: A simple gem checking for ssl expiry.
|