ssl_expiry 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 +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +33 -0
- data/.travis.yml +33 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/check-ssl +64 -0
- data/lib/ssl_expiry/errors.rb +3 -0
- data/lib/ssl_expiry/version.rb +3 -0
- data/lib/ssl_expiry.rb +86 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/ssl_expiry_spec.rb +7 -0
- data/ssl_expiry.gemspec +31 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1422f1ec006b1e5b1de78ab781b7c858be3f4d10962af83496d3bb6a4283ef9
|
4
|
+
data.tar.gz: 88159051111d5f1189de0a9b9878b0ece769635388352ae3db06306a66cd9e49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fd33a040f868ffec0e5e7ca8eded206990949de26f2d16bb4e399ec86a891a0bcf06e5130e360a680edac92267ee688cab0a204d370a09d7609dd494ae985b1
|
7
|
+
data.tar.gz: fb83812821356940312e3484ba43920bb77e0e4504d5ab42fe5f68f1c019e402af33152845887f59a1ed667ec0369b18979712669b3055ac26d3fa83bd0e6a7b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Layout/IndentationWidth:
|
2
|
+
Width: 4
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Max: 50
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Max: 40
|
12
|
+
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Max: 20
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 60
|
18
|
+
|
19
|
+
Metrics/PerceivedComplexity:
|
20
|
+
Max: 20
|
21
|
+
|
22
|
+
Style/GlobalVars:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/RaiseArgs:
|
26
|
+
EnforcedStyle: compact
|
27
|
+
|
28
|
+
Style/RedundantBegin:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/WordArray:
|
32
|
+
EnforcedStyle: brackets
|
33
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
sudo: required
|
2
|
+
matrix:
|
3
|
+
include:
|
4
|
+
- language: ruby
|
5
|
+
rvm: 2.4.4
|
6
|
+
before_install:
|
7
|
+
- gem install bundler -v 1.17.3
|
8
|
+
- language: ruby
|
9
|
+
rvm: 2.4.4
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 2.0.1
|
12
|
+
- language: ruby
|
13
|
+
env: SKIP_INTERPRETER=true
|
14
|
+
rvm: 2.4.4
|
15
|
+
before_install:
|
16
|
+
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
17
|
+
install:
|
18
|
+
- ./rubocop-travis/install.sh
|
19
|
+
script:
|
20
|
+
- ./rubocop-travis/scan.sh
|
21
|
+
- language: ruby
|
22
|
+
rvm: 2.4.4
|
23
|
+
before_install:
|
24
|
+
- mkdir travis
|
25
|
+
- git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
|
26
|
+
install:
|
27
|
+
- ./travis/awesomebot/install.sh
|
28
|
+
script:
|
29
|
+
- ./travis/awesomebot/scan.sh
|
30
|
+
notifications:
|
31
|
+
email: false
|
32
|
+
slack:
|
33
|
+
secure: u3UC7xkXbiXgWeWkay1G2VBNzUfa6FUvLK4LtkxiaYeF/Y7uQ9As8EZ/0xeTHpr014XY8zTNwdYVntp5hBASxuH+43sWZKIeCRy0YxtQ97f6/0mRSKUVul73XvYcHMns/42Ho17OcAae70r9I59zKJSSz4I9+QnSkoCn1CgYzXGw8u4C9+WLxIbXyG7bKFwhsiIsHOJiBgWy+V9QG5tZfvlQwMwIAlQ0dkwiIkQ3DMq2NpCawFhL0as8f6VatJZMU+D3CG9EU28965rdrivAZ1emJky5HFJ/ZKeacTtbDijFTpeFS7G6ZH+4LavdyFjWCH3hsdIgQ3AhL/F/JjioIIOL6U9pnJbmnihHaxLM/l9wOovmmbjoe/mZPmTtdoUUebY1RBeAp+3l5xz4HOb8zIaPDoejMs75gysXboXQSSLW6oga6XKUNBLyf8PNc5KowoLh2Q2CZV0HyJHwlp3jCUA2E5cL04iGaLpcDTP+vm4zrHD4ICd89EQumyXesowxcyahWTPlH5+CxHSxsJ66peRHHqEW4Si9zR0ssWjmhfzGcoIfMVwPOFwOG/qxvxFAM24tCyOwaSmW1vQXSVFsZ7FHap+lG9yKOKV9Q2ZBREPX0pAJ8ST6zVE6Q4ppOv7t8nGALhjSsXzIOoWqfZdvH0ktyJYo6bpEw/e8YdmRfw8=
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tim.gurney@timgurney.net. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Tim Gurney
|
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,95 @@
|
|
1
|
+
[![Build Status](https://img.shields.io/travis/AntiPhotonltd/ssl_expiry/master.svg)](https://travis-ci.org/AntiPhotonltd/ssl_expiry)
|
2
|
+
[![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
|
3
|
+
[![Release](https://img.shields.io/github/release/AntiPhotonltd/ssl_expiry.svg)](https://github.com/AntiPhotonltd/ssl_expiry/releases/latest)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/ssl_expiry.svg)](https://badge.fury.io/rb/ssl_expiry)
|
5
|
+
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/AntiPhotonltd/ssl_expiry/latest.svg)](https://github.com/AntiPhotonltd/ssl_expiry/commits)
|
6
|
+
[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/AntiPhotonltd/ssl_expiry.svg)](https://github.com/AntiPhotonltd/ssl_expiry)
|
7
|
+
[![GitHub contributors](https://img.shields.io/github/contributors/AntiPhotonltd/ssl_expiry.svg)](https://github.com/AntiPhotonltd/ssl_expiry)
|
8
|
+
|
9
|
+
# SSL Expiry
|
10
|
+
|
11
|
+
This is a simple little gem for checking when an SSL will expire.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'ssl_expiry'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install ssl_expiry
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Simple Usage
|
32
|
+
```ruby
|
33
|
+
require 'ssl_expiry'
|
34
|
+
|
35
|
+
SSLExpiry::SSLExpiry.check_certificates('antiphoton.com')
|
36
|
+
|
37
|
+
Results:
|
38
|
+
{"antiphoton.com"=>{"status"=>200, "expires_on"=>"09 Mar 2019", "expires_in"=>16, "common_name"=>"antiphoton.com", "issuer"=>"COMODO CA Limited"}}
|
39
|
+
```
|
40
|
+
|
41
|
+
### Displaying the output
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'ssl_expiry'
|
45
|
+
|
46
|
+
results = SSLExpiry::SSLExpiry.check_certificates(['antiphoton.com','wolfsoftware.com'])
|
47
|
+
SSLExpiry::SSLExpiry.display_results(results)
|
48
|
+
```
|
49
|
+
|
50
|
+
This would give the following output
|
51
|
+
|
52
|
+
```shell
|
53
|
+
----------------------------------------------------------------------------------------------------
|
54
|
+
Domain | Status
|
55
|
+
----------------------------------------------------------------------------------------------------
|
56
|
+
antiphoton.com | expires on 09 Mar 2019 (in 16 days) [CN=antiphoton.com]
|
57
|
+
wolfsoftware.com | expires on 12 Sep 2019 (in 203 days) [CN=*.wolfsoftware.com]
|
58
|
+
----------------------------------------------------------------------------------------------------
|
59
|
+
```
|
60
|
+
|
61
|
+
## Command Line Tools
|
62
|
+
|
63
|
+
There is a command line tool included with this gem.
|
64
|
+
|
65
|
+
```shell
|
66
|
+
check-ssl -d antiphoton.com
|
67
|
+
|
68
|
+
----------------------------------------------------------------------------------------------------
|
69
|
+
Domain | Status
|
70
|
+
----------------------------------------------------------------------------------------------------
|
71
|
+
antiphoton.com | expires on 09 Mar 2019 (in 16 days) [CN=antiphoton.com]
|
72
|
+
----------------------------------------------------------------------------------------------------
|
73
|
+
```
|
74
|
+
|
75
|
+
## Development
|
76
|
+
|
77
|
+
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.
|
78
|
+
|
79
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
80
|
+
|
81
|
+
## Testing
|
82
|
+
|
83
|
+
For local testing make sure that you run `bundle exec rspec spec` and then `rake install` to install the gem locally.
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/ssl_expiry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
92
|
+
|
93
|
+
## Code of Conduct
|
94
|
+
|
95
|
+
Everyone interacting in the SSLExpiry project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AntiPhotonltd/ssl_expiry/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ssl_expiry"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/check-ssl
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'ssl_expiry'
|
5
|
+
|
6
|
+
# -------------------------------------------------------------------------------- #
|
7
|
+
# Process Arguments #
|
8
|
+
# -------------------------------------------------------------------------------- #
|
9
|
+
# This function will process the input from the command line and work out what it #
|
10
|
+
# is that the user wants to see. #
|
11
|
+
# #
|
12
|
+
# This is the main processing function where all the processing logic is handled. #
|
13
|
+
# -------------------------------------------------------------------------------- #
|
14
|
+
|
15
|
+
def process_arguments
|
16
|
+
options = {}
|
17
|
+
# Enforce the presence of
|
18
|
+
mandatory = %I[domain]
|
19
|
+
|
20
|
+
optparse = OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
22
|
+
|
23
|
+
opts.on('-h', '--help', 'Display this screen') do
|
24
|
+
puts opts
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
opts.on('-d', '--domain string', 'The domain name to check') do |domain|
|
28
|
+
options[:domain] = domain
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
optparse.parse!
|
34
|
+
options[:message] = ARGF.read if !STDIN.tty? # override message parameter if data is piped in
|
35
|
+
missing = mandatory.select { |param| options[param].nil? }
|
36
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
37
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
38
|
+
puts e.to_s
|
39
|
+
puts optparse
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
results = SSLExpiry::SSLExpiry.check_certificates(options[:domain])
|
44
|
+
SSLExpiry::SSLExpiry.display_results(results)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# -------------------------------------------------------------------------------- #
|
49
|
+
# Main() #
|
50
|
+
# -------------------------------------------------------------------------------- #
|
51
|
+
# The main function where all of the heavy lifting and script config is done. #
|
52
|
+
# -------------------------------------------------------------------------------- #
|
53
|
+
|
54
|
+
def main
|
55
|
+
process_arguments
|
56
|
+
end
|
57
|
+
|
58
|
+
main
|
59
|
+
|
60
|
+
# -------------------------------------------------------------------------------- #
|
61
|
+
# End of Script #
|
62
|
+
# -------------------------------------------------------------------------------- #
|
63
|
+
# This is the end - nothing more to see here. #
|
64
|
+
# -------------------------------------------------------------------------------- #
|
data/lib/ssl_expiry.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'ssl_expiry/errors'
|
2
|
+
require 'ssl_expiry/version'
|
3
|
+
|
4
|
+
require 'net/http'
|
5
|
+
require 'openssl'
|
6
|
+
|
7
|
+
#
|
8
|
+
# Docs to follow
|
9
|
+
#
|
10
|
+
module SSLExpiry
|
11
|
+
#
|
12
|
+
# Docs to follow
|
13
|
+
#
|
14
|
+
class SSLExpiry
|
15
|
+
def self.get_cert(domain_name, verify = false)
|
16
|
+
begin
|
17
|
+
cert = nil
|
18
|
+
|
19
|
+
uri = URI::HTTPS.build(host: domain_name)
|
20
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
21
|
+
|
22
|
+
http.use_ssl = true
|
23
|
+
http.verify_mode = verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
24
|
+
http.open_timeout = 10
|
25
|
+
http.read_timeout = 10
|
26
|
+
http.ssl_timeout = 10
|
27
|
+
|
28
|
+
http.start do |h|
|
29
|
+
cert = h.peer_cert
|
30
|
+
end
|
31
|
+
|
32
|
+
cert
|
33
|
+
rescue SocketError, SystemCallError
|
34
|
+
raise SSLError.new "Bad URL? #{$ERROR_INFO.message}"
|
35
|
+
rescue Net::OpenTimeout
|
36
|
+
raise SSLError.new 'Timed out. Is the site up?'
|
37
|
+
rescue OpenSSL::SSL::SSLError
|
38
|
+
raise SSLError.new "We're trying to validate your certificate using TLSv1 It looks like your server doesn't accept it: [#{$ERROR_INFO.message}]" if $ERROR_INFO.message =~ /sslv3.+tlsv1 alert/i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.check_certificates(domains, date_format = '%d %b %Y')
|
43
|
+
results = {}
|
44
|
+
|
45
|
+
domains = domains.split(',') unless domains.is_a?(Array)
|
46
|
+
|
47
|
+
domains.each do |domain|
|
48
|
+
begin
|
49
|
+
cert = get_cert(domain)
|
50
|
+
rescue SSLError => e
|
51
|
+
results[domain] = { 'status' => 400, 'error' => e.message }
|
52
|
+
next
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
common_name = cert.subject.to_a.select { |name, _data, _type| name == 'CN' }.first[1]
|
57
|
+
issuer = cert.issuer.to_a.select { |name, _data, _type| name == 'O' }.first[1]
|
58
|
+
expires_on = cert.not_after
|
59
|
+
num_days = ((expires_on - Time.now) / 864_00).to_i
|
60
|
+
|
61
|
+
results[domain] = { 'status' => 200, 'expires_on' => expires_on.strftime(date_format), 'expires_in' => num_days, 'common_name' => common_name, 'issuer' => issuer }
|
62
|
+
rescue StandardError
|
63
|
+
results[domain] = { 'status' => 400, 'error' => 'Parsing error' }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
results.sort
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.display_results(results, width = 120)
|
70
|
+
delim = '-' * width
|
71
|
+
|
72
|
+
puts(delim)
|
73
|
+
printf(" %-30s | %s\n", 'Domain', 'Status')
|
74
|
+
puts(delim)
|
75
|
+
results.each do |domain, details|
|
76
|
+
status = if details['status'] == 400
|
77
|
+
details['error']
|
78
|
+
else
|
79
|
+
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'])
|
80
|
+
end
|
81
|
+
printf(" %-30s | %s\n", domain, status)
|
82
|
+
end
|
83
|
+
puts(delim)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'ssl_expiry'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
|
15
|
+
original_stderr = $stderr
|
16
|
+
original_stdout = $stdout
|
17
|
+
config.before(:all) do
|
18
|
+
# Redirect stderr and stdout
|
19
|
+
$stderr = File.open(File::NULL, 'w')
|
20
|
+
$stdout = File.open(File::NULL, 'w')
|
21
|
+
end
|
22
|
+
config.after(:all) do
|
23
|
+
$stderr = original_stderr
|
24
|
+
$stdout = original_stdout
|
25
|
+
end
|
26
|
+
end
|
data/ssl_expiry.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ssl_expiry/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ssl_expiry"
|
8
|
+
spec.version = SSLExpiry::VERSION
|
9
|
+
spec.authors = ['Tim Gurney aka Wolf']
|
10
|
+
spec.email = ['wolf@tgwolf.com']
|
11
|
+
|
12
|
+
spec.summary = %q{A simple gem checking for ssl expiry.}
|
13
|
+
spec.description = %q{A simple gem checking for ssl expiry.}
|
14
|
+
spec.homepage = 'https://github.com/AntiPhotonltd/ssl_expiry'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
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_development_dependency "bundler", "~> 2"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
|
26
|
+
spec.add_development_dependency 'openssl', '~> 2'
|
27
|
+
spec.add_development_dependency 'net-http-persistent', '~> 3'
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'openssl', '~> 2'
|
30
|
+
spec.add_runtime_dependency 'net-http-persistent', '~> 3'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ssl_expiry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Gurney aka Wolf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: openssl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: net-http-persistent
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: openssl
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: net-http-persistent
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3'
|
111
|
+
description: A simple gem checking for ssl expiry.
|
112
|
+
email:
|
113
|
+
- wolf@tgwolf.com
|
114
|
+
executables:
|
115
|
+
- check-ssl
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
124
|
+
- CODE_OF_CONDUCT.md
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/console
|
130
|
+
- bin/setup
|
131
|
+
- exe/check-ssl
|
132
|
+
- lib/ssl_expiry.rb
|
133
|
+
- lib/ssl_expiry/errors.rb
|
134
|
+
- lib/ssl_expiry/version.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/ssl_expiry_spec.rb
|
137
|
+
- ssl_expiry.gemspec
|
138
|
+
homepage: https://github.com/AntiPhotonltd/ssl_expiry
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.0.2
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: A simple gem checking for ssl expiry.
|
161
|
+
test_files: []
|