ssl_info 1.0.1 → 1.0.2
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 +7 -0
- data/lib/ssl_info.rb +15 -4
- data/lib/ssl_info/version.rb +1 -1
- data/testing/ssl-info +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: 954c1cd2baee5c80f1a8d9d961080beb4ea5191333663424b624ebd55ef18d12
|
4
|
+
data.tar.gz: a813187fe11d87d6b0eeb1250e61a2d09946cc8a2e8a0a624453919bf9c74e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03cd10b89305d2092e56b72126abab8cbd24e4674791fcd85359a1c114e3c12c1a34b449074f9e6c96fe54c7a3785ed0686fb317b8e43c3a9c3399f78c68d6aa
|
7
|
+
data.tar.gz: c10a8d92e25aa805dc18a3f2786432650297b269c28f45d3f2a01246a031abb52765d7ed0415c3c3b48767947f1a9cb66ad9ca45506e6541f0648edbf83f0b60
|
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
@@ -42,6 +42,13 @@ printf("Expires: #{SSLInfo.not_after}\n")
|
|
42
42
|
printf("Expires In: #{SSLInfo.expires_in} days\n")
|
43
43
|
```
|
44
44
|
|
45
|
+
> You can add an optional port to the domain name.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
SSLInfo.get_cert("www.antiphoton.com:8080")
|
49
|
+
SSLInfo.display_cert
|
50
|
+
```
|
51
|
+
|
45
52
|
## Development
|
46
53
|
|
47
54
|
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_info.rb
CHANGED
@@ -21,14 +21,25 @@ module SSLInfo
|
|
21
21
|
|
22
22
|
def self.get_cert(domain_name, verify = false)
|
23
23
|
begin
|
24
|
+
parts = domain_name.split(':')
|
25
|
+
|
26
|
+
domain_name = parts[0]
|
27
|
+
|
24
28
|
uri = URI::HTTPS.build(host: domain_name)
|
25
|
-
|
29
|
+
|
30
|
+
port = if parts.length == 1
|
31
|
+
uri.port
|
32
|
+
else
|
33
|
+
parts[1]
|
34
|
+
end
|
35
|
+
|
36
|
+
http = Net::HTTP.new(uri.host, port)
|
26
37
|
|
27
38
|
http.use_ssl = true
|
28
39
|
http.verify_mode = verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
29
|
-
http.open_timeout =
|
30
|
-
http.read_timeout =
|
31
|
-
http.ssl_timeout =
|
40
|
+
http.open_timeout = 5
|
41
|
+
http.read_timeout = 5
|
42
|
+
http.ssl_timeout = 5
|
32
43
|
|
33
44
|
http.start do |h|
|
34
45
|
@cert = h.peer_cert
|
data/lib/ssl_info/version.rb
CHANGED
data/testing/ssl-info
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_info'
|
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
|
+
SSLInfo.get_cert(options[:domain])
|
47
|
+
SSLInfo.display_cert unless SSLInfo.cert.nil?
|
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_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
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
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- spec/spec_helper.rb
|
142
142
|
- spec/ssl_info_spec.rb
|
143
143
|
- ssl_info.gemspec
|
144
|
+
- testing/ssl-info
|
144
145
|
homepage: https://github.com/AntiPhotonltd/ssl_info
|
145
146
|
licenses:
|
146
147
|
- MIT
|
@@ -160,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
161
|
- !ruby/object:Gem::Version
|
161
162
|
version: '0'
|
162
163
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
+
rubygems_version: 3.1.2
|
164
165
|
signing_key:
|
165
166
|
specification_version: 4
|
166
167
|
summary: A simple gem for retreiving and displaying SSL certificate information.
|