ssl-test 0.0.2 → 1.0.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
- data/README.md +9 -0
- data/lib/ssl-test.rb +4 -2
- data/test/ssl-test_test.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e444097317630bf487a1e1c4c55baa00de963656
|
4
|
+
data.tar.gz: e82c53db8ae5371c3b6a77b5d7ac7b04064c09a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da985b40c54ed631ddcc262b376b478660e2a294d66e42d910cfeb1663dc75bfd4ec491c572f2d04646738741607ad788eedf65872d084ef32a46dcb8c1c6b62
|
7
|
+
data.tar.gz: 40831c9f53c00a65f3f76866f8b4cf967faf3b1a289441094187dacdd948398733fa1665671c34e04e802b4d4e28dcc420a08b1840770827ce4307279e2cdc05
|
data/README.md
CHANGED
@@ -38,6 +38,15 @@ error # => "SSL certificate test failed: getaddrinfo: Name or service not known"
|
|
38
38
|
cert # => nil
|
39
39
|
```
|
40
40
|
|
41
|
+
You can also pass custom timeout values:
|
42
|
+
```ruby
|
43
|
+
valid, error, cert = SSLTest.test "https://slowebsite.com", open_timeout: 2, read_timeout: 2
|
44
|
+
valid # => nil
|
45
|
+
error # => "SSL certificate test failed: execution expired"
|
46
|
+
cert # => nil
|
47
|
+
```
|
48
|
+
Default timeout values are 5 seconds each (open and read)
|
49
|
+
|
41
50
|
## How it works
|
42
51
|
|
43
52
|
SSLTester simply performs a HEAD request using ruby `net/https` library and verifies the SSL status. It also hooks into the validation process to intercept the raw certificate for you.
|
data/lib/ssl-test.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
require "net/https"
|
2
2
|
|
3
3
|
module SSLTest
|
4
|
-
VERSION = "0.0
|
4
|
+
VERSION = "1.0.0"
|
5
5
|
|
6
|
-
def self.test url
|
6
|
+
def self.test url, open_timeout: 5, read_timeout: 5
|
7
7
|
uri = URI.parse(url)
|
8
8
|
return if uri.scheme != 'https'
|
9
9
|
cert = failed_cert_reason = nil
|
10
10
|
|
11
11
|
http = Net::HTTP.new(uri.host, uri.port)
|
12
|
+
http.open_timeout = open_timeout
|
13
|
+
http.read_timeout = read_timeout
|
12
14
|
http.use_ssl = true
|
13
15
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
14
16
|
http.verify_callback = -> (verify_ok, store_context) {
|
data/test/ssl-test_test.rb
CHANGED
@@ -39,6 +39,13 @@ describe SSLTest do
|
|
39
39
|
cert.must_be_nil
|
40
40
|
end
|
41
41
|
|
42
|
+
it "stops on timeouts" do
|
43
|
+
valid, error, cert = SSLTest.test("https://approachio.com", open_timeout: 1)
|
44
|
+
valid.must_be_nil
|
45
|
+
error.must_equal "SSL certificate test failed: execution expired"
|
46
|
+
cert.must_be_nil
|
47
|
+
end
|
48
|
+
|
42
49
|
# Not implemented yet
|
43
50
|
# it "returns error on revoked cert" do
|
44
51
|
# valid, error, cert = SSLTest.test("https://revoked.grc.com")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssl-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Jarthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.4.5.1
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Test website SSL certificate validity
|